driftwood.handlers package

Submodules

driftwood.handlers.dict module

class driftwood.handlers.dict.DictHandler(*args, regular_attrs=None, extra_attrs=, []**kwargs)[source]

Bases: logging.Handler

Formats log records into a dict.

Meant to be subclassed. This is just a convenience wrapper around driftwood.formatters.dict.DictFormatter.

Parameters:extra_attrs (list) – String names of extra attributes that may exist on the log record.
emit(record)[source]

Super this in your subclass to format the record into a dict

driftwood.handlers.mongo module

class driftwood.handlers.mongo.MongoHandler(*args, document=<MagicMock spec='str' id='140725196754672'>, **kwargs)[source]

Bases: driftwood.handlers.dict.DictHandler

A handler that will log to MongoDB for you.

Parameters:mongoengine.Document (document) – The document that should be used for storing log messages. Defaults to driftwood.handlers.mongo.LogRecord. If you are using extra_attrs parameter of DictHandler, you must define your own document.

Additionally accepts the same arguments as DictHandler

emit(record)[source]

Converts the log record into a mongoengine document and saves it.

You can subclass and override this to do neat things.

Module contents