Working with Logger adapters¶
N.B. This is part of the standard library since Python 2.6 / 3.1, so the version here is for use with earlier Python versions.
The class was enhanced for Python 3.2, so you may wish to use this version with earlier Python versions.
However, note that the LoggerAdapter
class will not
work with Python 2.4 or earlier, as it uses the extra keyword argument which
was added in later Python versions.
- class logutils.adapter.LoggerAdapter(logger, extra)¶
An adapter for loggers which makes it easier to specify contextual information in logging output.
- critical(msg, *args, **kwargs)¶
Delegate a critical call to the underlying logger.
- debug(msg, *args, **kwargs)¶
Delegate a debug call to the underlying logger.
- error(msg, *args, **kwargs)¶
Delegate an error call to the underlying logger.
- exception(msg, *args, **kwargs)¶
Delegate an exception call to the underlying logger.
- getEffectiveLevel()¶
Get the effective level for the underlying logger.
- hasHandlers()¶
See if the underlying logger has any handlers.
- info(msg, *args, **kwargs)¶
Delegate an info call to the underlying logger.
- isEnabledFor(level)¶
Is this logger enabled for level ‘level’?
- log(level, msg, *args, **kwargs)¶
Delegate a log call to the underlying logger, after adding contextual information from this adapter instance.
- 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.
- setLevel(level)¶
Set the specified level on the underlying logger.
- warn(msg, *args, **kwargs)¶
Delegate a warning call to the underlying logger.
- warning(msg, *args, **kwargs)¶
Delegate a warning call to the underlying logger.