amprolla

devuan's apt repo merger
git clone git://parazyd.org/amprolla.git
Log | Files | Refs | README | LICENSE

commit e3fff494910cd263d90119ac1b73aef6d830446e
parent 76cbe816ad7cdfe728dcbea24029ecaedbc1287d
Author: parazyd <parazyd@dyne.org>
Date:   Sat,  9 Dec 2017 11:27:39 +0100

Use different timestamp for log messages

Diffstat:
Mlib/log.py | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/log.py b/lib/log.py @@ -4,7 +4,7 @@ Logging functions """ -from time import time +from time import strftime from os import makedirs from os.path import join import sys @@ -12,11 +12,18 @@ import sys from lib.config import logdir +def timestamp(): + """ + Return current time in a certain format. + """ + return strftime("%Y/%m/%d %H:%M:%S") + + def die(msg, tofile=True): """ Log error and exit with exitcode 1 """ - msg = "%d [ERR] %s" % (int(time()), msg) + msg = "%s [ERR] %s" % (timestamp(), msg) print(msg) if tofile: logtofile('amprolla.txt', msg+'\n') @@ -27,7 +34,7 @@ def warn(msg, tofile=True): """ Log warning and continue """ - msg = "%d [WARN] %s" % (int(time()), msg) + msg = "%s [WARN] %s" % (timestamp(), msg) print(msg) if tofile: logtofile('amprolla.txt', msg+'\n') @@ -37,7 +44,7 @@ def info(msg, tofile=True): """ Log informational message and continue """ - msg = "%d [INFO] %s" % (int(time()), msg) + msg = "%s [INFO] %s" % (timestamp(), msg) print(msg) if tofile: logtofile('amprolla.txt', msg+'\n')