sawmill.formatter.field

class sawmill.formatter.field.Field(keys, missing_key='__SKIP__', template='{key}={value}', item_separator=':')[source]

Bases: sawmill.formatter.base.Formatter

Format logs according to item list.

REMAINING = '*'
__init__(keys, missing_key='__SKIP__', template='{key}={value}', item_separator=':')[source]

Initialise formatter with keys to look for in specific order.

keys may contain REMAINING at any point to include all remaining unspecified keys in alphabetical order.

missing_key determines how to handle a missing key when formatting a log. The default SKIP will skip the key and not include it in the resulting output. ERROR will cause a KeyError to be raised. Any other value will be used as the substitute string for the missing value.

template is used to format the key and value of each field and item_separator will separate each item.

format(logs)[source]

Return formatted data representing logs.

ERROR = '__ERROR__'
SKIP = '__SKIP__'