sawmill.handler.base

class sawmill.handler.base.Handler(filterer=None, formatter=None)[source]

Bases: object

Handle a Log, outputting it in a relevant way.

__init__(filterer=None, formatter=None)[source]

Initialise handler with filterer and formatter.

If specified, filterer should be an instance of Filterer and will be used to determine whether to handle a log or not.

formatter should be an instance of Formatter and will be called to format the log record into a format suitable for output by this handler. As such a contractual relationship exists between a handler and its formatter.

setup()[source]

Setup handler.

teardown()[source]

Teardown handler.

handle(*logs)[source]

Output formatted logs that pass defined filters.

output(data)[source]

Output formatted data.

data should be a list of entries (typically one per log) to output.

Warning

data may be shared and should not be altered.