49 How do I duplicate sys.stdout to a log file in python? 50 https://stackoverflow.com/questions/616645/how-do-i-duplicate-sys-stdout-to-a-log-file-in-python 54 def __init__(self, stdout=False, ignoredefault=False):
55 """ If `ignoredefault` is True, only write to this object stream. 79 @return `True` if the file has been closed. 85 The try/except block is in case this is called at program exit time, when it's possible 86 that globals have already been deleted, and then the close() call might fail. Since 87 there's nothing we can do about such failures and they annoy the end users, we suppress 89 https://github.com/python/cpython/blob/1fd06f1eca80dcbf3a916133919482a8327f3da4/Lib/_pyio.py#L380 91 python Exception AttributeError: “'NoneType' object has no attribute 'var'” 92 https://stackoverflow.com/questions/9750308/python-exception-attributeerror-nonetype-object-has-no-attribute-var 101 def clear(self, log=None):
111 except AttributeError:
119 def writeboth(self, *args, **kwargs):
125 def writethis(self, *args, **kwargs):
130 def contents(self, date_regex=""):
134 def file_contents(self, log, date_regex=""):
136 with io.open( log.output_file,
"r", encoding='utf-8', newline=None ) as file: 143 def _process_contents(self, date_regex, output):
145 date_regex_pattern = re.compile( date_regex )
147 output = output.strip().split(
"\n" )
150 clean_output.append( date_regex_pattern.sub(
"", line ) )
152 return "\n".join( clean_output )