Permanently redirects logging to the stdlib. This also removes all otherwise registered handlers on root logger of the logging system but leaves the other loggers untouched.
Temporarily redirects logging for all threads and reverts it later to the old handlers. Mainly used by the internal unittests:
from logbook.compat import redirected_logging with redirected_logging(): ...
If you want to customize the redirecting you can subclass it.
Converts a logging level into a logbook level.
Converts an old logging record into a logbook log record.
Converts the UNIX timestamp of the old record into a datetime object as used by logbook.
Tries to find the caller that issued the call.
Tries to find custom data from the old logging record. The return value is a dictionary that is merged with the log record extra dictionaries.
Does the opposite of the RedirectLoggingHandler, it sends messages from logbook to logging. Because of that, it’s a very bad idea to configure both.
This handler is for logbook and will pass stuff over to a logger from the standard library.
from logbook.compat import LoggingHandler, warn with LoggingHandler(): warn('This goes to logging')
Converts a logbook level into a logging level.
Converts a record from logbook to logging.
Converts a datetime object into a timestamp.
Returns the logger to use for this record. This implementation always return logger.
Like redirected_warnings() but will redirect all warnings to the shutdown of the interpreter:
from logbook.compat import redirect_warnings redirect_warnings()
A context manager that copies and restores the warnings filter upon exiting the context, and logs warnings using the logbook system.
The channel attribute of the log record will be the import name of the warning.
from logbook.compat import redirected_warnings from warnings import warn with redirected_warnings(): warn(DeprecationWarning('logging should be deprecated'))