sawmill.compatibility

sawmill.compatibility.redirect_standard_library_logging()[source]

Redirect standard library logging to Sawmill.

Replace any existing handlers on the standard library root logger with a single RedirectToSawmillHandler. Other handlers should be left untouched.

In addition, unset any level filter on the standard library root logger to ensure logs are passed through.

class sawmill.compatibility.RedirectToSawmillHandler(target=<sawmill.handler.distribute.Distribute object>, *args, **kwargs)[source]

Bases: logging.Handler

Redirect to Sawmill.

__init__(target=<sawmill.handler.distribute.Distribute object>, *args, **kwargs)[source]

Initialise handler.

target should be the Sawmill handler to redirect to.

emit(record)[source]

Emit record to Sawmill.

Note

It is the responsibility of the attached formatter to convert the record to a Sawmill Log instance.

class sawmill.compatibility.SawmillFormatter[source]

Bases: logging.Formatter

Format records for use by Sawmill.

__init__()[source]

Initialise formatter.

format(record)[source]

Return Sawmill Log instance from record.