sawmill.filterer.pattern

class sawmill.filterer.pattern.Pattern(pattern, key='name', mode='include')[source]

Bases: sawmill.filterer.base.Filterer

Filter logs using pattern matching.

__init__(pattern, key='name', mode='include')[source]

Initialise filterer with pattern and key to test.

If pattern is a string it will be converted to a compiled regular expression instance.

mode can be either ‘exclude’ or ‘include’. If set to ‘exclude’ then any log matching the pattern will be filtered. Conversely, if set to ‘include’ then any log not matching the pattern will be filtered.

EXCLUDE = 'exclude'
INCLUDE = 'include'
filter(logs)[source]

Filter logs based on pattern matching.

If a log does not have the key to test against it will pass the filter successfully. If the key is present, but not a string then the log will be filtered.