diff options
Diffstat (limited to 'python/vyos/debug.py')
-rw-r--r-- | python/vyos/debug.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/python/vyos/debug.py b/python/vyos/debug.py index 1a042cbb4..60e5291c1 100644 --- a/python/vyos/debug.py +++ b/python/vyos/debug.py @@ -15,7 +15,7 @@ import os import sys - +from datetime import datetime def message(message, flag='', destination=sys.stdout): """ @@ -46,7 +46,7 @@ def message(message, flag='', destination=sys.stdout): mask = os.umask(0o111) with open(logfile, 'a') as f: - f.write(_format('log', message)) + f.write(_timed(_format('log', message))) finally: os.umask(mask) @@ -81,6 +81,11 @@ def enabled(flag): return _fromenv(flag) or _fromfile(flag) +def _timed(message): + now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + return f'{now} {message}' + + def _format(flag, message): """ format a log message |