Fallback automatically to a log file if we can detect one, even tho file was never given in the log() call. This might cause some log posts to slip in to the logs, but use suppress=True to force-ignore those in such a case.

This commit is contained in:
Anton Hvornum 2020-11-05 00:36:19 +00:00
parent c22e986874
commit 216917b9c3
1 changed files with 3 additions and 0 deletions

View File

@ -80,6 +80,9 @@ def log(*args, **kwargs):
kwargs = {'bg' : 'black', 'fg': 'white', **kwargs}
string = stylize_output(string, **kwargs)
if (logfile := storage.get('logfile', None)) and 'file' not in kwargs:
kwargs['file'] = logfile
# Log to a file output unless specifically told to suppress this feature.
# (level has no effect on the log file, everything will be written there)
if 'file' in kwargs and ('suppress' not in kwargs or kwargs['suppress'] == False):