3. Source doc¶
3.1. Module quicklogging¶
(logging with a bit of cozyness)
3.1.1. log wrappers¶
Supplied convenience functions fetch a logger with the name of the module from which you’re calling them.
-
quicklogging.debug(*args, **kwargs)[source]¶ wrapper for
logging.Logger.debug()Variadic parameters: see
logging.Logger.debug()Parameters: stackoverhead (int) – see quicklogging.base.get_logger()
-
quicklogging.info(*args, **kwargs)[source]¶ wrapper for
logging.Logger.info()Variadic parameters: see
logging.Logger.info()Parameters: stackoverhead (int) – see quicklogging.base.get_logger()
-
quicklogging.warning(*args, **kwargs)[source]¶ wrapper for
logging.Logger.warning()Variadic parameters: see
logging.Logger.warning()Parameters: stackoverhead (int) – see quicklogging.base.get_logger()
-
quicklogging.error(*args, **kwargs)[source]¶ wrapper for
logging.Logger.error()Variadic parameters: see
logging.Logger.error()Parameters: stackoverhead (int) – see quicklogging.base.get_logger()
-
quicklogging.critical(*args, **kwargs)[source]¶ wrapper for
logging.Logger.critical()Variadic parameters: see
logging.Logger.critical()Parameters: stackoverhead (int) – see quicklogging.base.get_logger()
-
quicklogging.exception(*args, **kwargs)[source]¶ wrapper for
logging.Logger.exception()Variadic parameters: see
logging.Logger.exception()Parameters: stackoverhead (int) – see quicklogging.base.get_logger()
3.1.2. print handlers¶
-
quicklogging.catch_prints(catch_module=<object object>, catch_all=False, include_children=True, logfunc=<function info>)[source]¶ configure the print() catching: redirects calls to a logger
By default, only catches calls to print() from logger
- named after the calling module
- children of this logger
Note
API discussion welcome.
You anderstand the API is not stable.
Parameters: - catch_module (string) – include children of logger designed by name
- catch_all (bool) –
should catch all print() diregarding where they’re from ?
Warning
take care of logging propagation (
Logger.propagate()̀) - logfunc (function) – function to use for logging messages
Possible extension ideas:
- wrap arbitrary output stream
- different log functions depending on regex applied on messages
- make it configurable from config file
- allow exclusion of specific modules
3.2. Module quicklogging.base¶
-
quicklogging.base.get_logger(stackoverhead=0)[source]¶ wrapper for getLogger
Typical use, say you’re in project/module/submodule.py and you want a logger.
l = get_logger() print(l)
<logging.Logger at ... >
print(l.name)
project.module.submodule
Parameters: stackoverhead (int) – defaults to 0. How deep to look in the stack for fetching the logger name. Returns: a logger named after the module at depth stackoverhead.Return type: logging.Logger
-
quicklogging.base._log_with_level(func_name, *args, **kwargs)[source]¶ Internal convenience function to log with appropriate level
This function is called by the main log wrappers.
Fetches the appropriate logger, then the function named after the param
func_name. This is slow, you’d better use :py:func`get_logger`.Parameters: Return type: