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.BaseLogRecord(*args, **values)[source]

Bases: mongoengine.document.Document

Template for log records.

Allows subclassing to create your own log record document if you will be logging extra attributes.

Initialise a document or embedded document

Parameters:
  • __auto_convert – Try and will cast python objects to Object types
  • values – A dictionary of values for the document
created

An floating point number field.

filename

A unicode string field.

funcName

A unicode string field.

levelname

A unicode string field.

levelno

An 32-bit integer field.

lineno

An 32-bit integer field.

message

A unicode string field.

module

A unicode string field.

msecs

An floating point number field.

name

A unicode string field.

pathname

A unicode string field.

process

An 32-bit integer field.

relativeCreated

An floating point number field.

thread

An 64-bit integer field.

threadName

A unicode string field.

class driftwood.handlers.mongo.LogRecord(*args, **values)[source]

Bases: driftwood.handlers.mongo.BaseLogRecord

Is used as the default document for log records.

May not be sublassed.

Initialise a document or embedded document

Parameters:
  • __auto_convert – Try and will cast python objects to Object types
  • values – A dictionary of values for the document
exception DoesNotExist

Bases: mongoengine.errors.DoesNotExist

exception LogRecord.MultipleObjectsReturned

Bases: mongoengine.errors.MultipleObjectsReturned

LogRecord.id

A field wrapper around MongoDB’s ObjectIds.

class driftwood.handlers.mongo.MongoHandler(*args, document=<class 'driftwood.handlers.mongo.LogRecord'>, **kwargs)[source]

Bases: driftwood.handlers.dict.DictHandler

A handler that will log to MongoDB for you.

Parameters:document (mongoengine.Document) – The document that should be used for storing log messages. Defaults to 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

class driftwood.handlers.MongoHandler(*args, document=<class 'driftwood.handlers.mongo.LogRecord'>, **kwargs)

Bases: driftwood.handlers.dict.DictHandler

A handler that will log to MongoDB for you.

Parameters:document (mongoengine.Document) – The document that should be used for storing log messages. Defaults to 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)

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

You can subclass and override this to do neat things.

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

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)

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