yagwr.logger
: Logging helpers
- class yagwr.logger.NamedLogger(logger, extra)
Bases:
logging.LoggerAdapter
A logging adapater that uses the passed name in square brackets as a prefix.
The
extra
arguments arename
, a string. Ifname
is not present or if it’sNone
, no prefix is used.Initialize the adapter with a logger and a dict-like object which provides contextual information. This constructor signature allows easy stacking of LoggerAdapters, if so desired.
You can effectively pass keyword arguments as shown in the following example:
adapter = LoggerAdapter(someLogger, dict(p1=v1, p2=”v2”))
- process(msg, kwargs)
Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.
Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.
- exception yagwr.logger.LoggerConfigError
Bases:
Exception
Exception raised when a configuration error is detected
- yagwr.logger.setup_logger(log_file, log_level, quiet, log_rotate=None, log_rotate_arg=None)
Setups the logging based on
log_file
,log_level
,quiet
.- Parameters
- Raises
LoggerConfigError – when the settings are incorrect