summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-05-08 19:14:09 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-05-08 19:14:09 +0100
commitff58182904882278a004f4d3d8082ec11adbe1ea (patch)
treef79a57f98a312897db529c47421c4f2c45a738e1 /python
parent3639a5610b590a64d6d56bee81dddd252994cfe5 (diff)
parent29dee3abb55d0f0c6b91b311f30521b45d7e46b6 (diff)
downloadvyos-1x-ff58182904882278a004f4d3d8082ec11adbe1ea.tar.gz
vyos-1x-ff58182904882278a004f4d3d8082ec11adbe1ea.zip
Merge branch 'current' of github.com:thomas-mangin/vyos-1x into T2417
Diffstat (limited to 'python')
-rw-r--r--python/vyos/debug.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/python/vyos/debug.py b/python/vyos/debug.py
index 91431a7bb..6ce42b173 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 _remove_invisible(string):
for char in ('\0', '\a', '\b', '\f', '\v'):
string = string.replace(char, '')