Belle II Software  release-08-01-10
LogReplacementFilter Class Reference

Public Member Functions

def __init__ (self, out, replacements)
 
def write (self, data)
 
def __getattr__ (self, name)
 

Private Attributes

 _out
 where to forward output
 
 _replacements
 what to replace
 
 _regex
 build a regular expression from dictionary keys
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def __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.

20  def __init__(self, out, replacements):
21  """Setup the forwarding and replacements
22 
23  Parameters:
24  out (file object): Where to forward the output too
25  replacements (dict(str, str)): Dictionary of strings and their replacements
26  """
27 
28  self._out = out
29 
30  self._replacements = replacements
31 
32  self._regex = re.compile("|".join(re.escape(e) for e in replacements))
33 

Member Function Documentation

◆ __getattr__()

def __getattr__ (   self,
  name 
)
Forward all other methods from the out stream

Definition at line 39 of file logfilter.py.

◆ write()

def write (   self,
  data 
)
Check all messages for strings to replace

Definition at line 34 of file logfilter.py.


The documentation for this class was generated from the following file: