Public Member Functions | |
__init__ (self, out, replacements) | |
write (self, data) | |
__getattr__ (self, name) | |
Protected Attributes | |
_out = out | |
where to forward output | |
_replacements = replacements | |
what to replace | |
_regex = re.compile("|".join(re.escape(e) for e in replacements)) | |
build a regular expression from dictionary keys | |
Simple class to intercept anything written to python stdout and replace a given set of strings with placehholders to improve reproducibility.
Definition at line 14 of file logfilter.py.
__init__ | ( | self, | |
out, | |||
replacements ) |
Setup the forwarding and replacements Parameters: out (file object): Where to forward the output too replacements (dict(str, str)): Dictionary of strings and their replacements
Definition at line 20 of file logfilter.py.
__getattr__ | ( | self, | |
name ) |
Forward all other methods from the out stream
Definition at line 39 of file logfilter.py.
write | ( | self, | |
data ) |
Check all messages for strings to replace
Definition at line 34 of file logfilter.py.
|
protected |
where to forward output
Definition at line 28 of file logfilter.py.
|
protected |
build a regular expression from dictionary keys
Definition at line 32 of file logfilter.py.
|
protected |
what to replace
Definition at line 30 of file logfilter.py.