rattail.logging

Logging Utilities

class rattail.logging.LuigiSummaryFilter(name='')[source]

Custom logging filter, to elevate the Luigi “execution summary” message to WARNING level, so that it shows up even when we ignore INFO logging.

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class rattail.logging.RattailAdapter(logger)[source]

Adds various items to a logger’s context.

Specifically, this adds the following keys to the extra dictionary available to the logger’s formatter(s):

  • 'hostname' - The fully-qualified domain name of the host machine.

  • 'hostip' - The IPv4 address of the host machine.

  • 'argv' - The value of sys.argv (a list).

  • 'uid' - The effective UID of the running process.

  • 'username' - The login name of the effective user.

process(msg, kwargs)[source]

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.

class rattail.logging.TimeConverter(config)[source]

Custom time converter for use with logging formatters. Makes sure the final effective time zone for logged timestamps is the “default” one.

rattail.logging.get_logger(name)[source]

Fetches a logger by name, and wraps it in an adapter.

This is intended to effectively replace the logging.getLogger() function. It does the same thing, except for wrapping the logger within a RattailAdapter.