This documents the internal API that might be useful for more advanced setups or custom handlers.
Passes a record on to the handlers on the stack. This is useful when log records are created programmatically and already have all the information attached and should be dispatched independent of a logger.
Baseclass for all objects that provide stack manipulation operations.
Can be used in combination with the with statement to execute code while the object is bound to the application.
Pops the stacked object from the application stack.
Pops the stacked object from the thread stack.
Pushes the stacked object to the application stack.
Pushes the stacked object to the thread stack.
Can be used in combination with the with statement to execute code while the object is bound to the thread.
A record dispatcher is the internal base class that implements the logic used by the Logger.
Pass a record to all relevant handlers in the following order:
Before the first handler is invoked, the record is processed (process_record()).
optionally the name of the group this logger belongs to
Call the handlers for the specified record. This is invoked automatically when a record should be handled. The default implementation checks if the dispatcher is disabled and if the record level is greater than the level of the record dispatcher. In that case it will call the handlers (call_handlers()).
list of handlers specific for this record dispatcher
the level of the record dispatcher as integer
Creates a record from some given arguments and heads it over to the handling system.
the name of the record dispatcher
Processes the record with all context specific processors. This can be overriden to also inject additional information as necessary that can be provided by this record dispatcher.
If this is set to True the dispatcher information will be suppressed for log records emitted from this logger.
This mixin class defines and implements the “usual” logger interface (i.e. the descriptive logging functions).
Classes using this mixin have to implement a handle() method which takes a LogRecord and passes it along.
A context manager that catches exceptions and calls exception() for exceptions caught that way. Example:
Works exactly like error() just that the message is optional and exception information is recorded.
The name of the minimium logging level required for records to be created.
Logs a LogRecord with the level set to the level parameter. Because custom levels are not supported by logbook, this method is mainly used to avoid the use of reflection (e.g.: getattr()) for programmatic logging.
Logs a LogRecord with the level set to NOTICE.
Alias for warn().
Baseclass for rotating file handlers.
Changed in version 0.3: This class was deprecated because the interface is not flexible enough to implement proper file rotations. The former builtin subclasses no longer use this baseclass.
Called if should_rollover() returns True and has to perform the actual rollover.
Called with the log record and the return value of the format_and_encode() method. The method has then to return True if a rollover should happen or False otherwise.
Changed in version 0.3: Previously this method was called with the number of bytes returned by format_and_encode()
A mixin for handlers that provides a default integration for the StringFormatter class. This is used for all handlers by default that log text to a destination.
a class attribute for the default format string to use if the constructor was invoked with None.
the currently attached format string as new-style format string.
the class to be used for string formatting
alias of StringFormatter