aboutsummaryrefslogtreecommitdiff
path: root/voctocore/lib
diff options
context:
space:
mode:
authorMaZderMind <github@mazdermind.de>2016-01-13 13:13:32 +0100
committerMaZderMind <github@mazdermind.de>2016-01-13 13:13:32 +0100
commit4cc574b84624b1ed33ce50a9122edddd001e0c27 (patch)
tree8346ba92a78b42f9c2884e87f2895639dc0df045 /voctocore/lib
parenta803d8dab73b88348625ab40695fce78390608b9 (diff)
reduce number of if/else cases
Diffstat (limited to 'voctocore/lib')
-rw-r--r--voctocore/lib/loghandler.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/voctocore/lib/loghandler.py b/voctocore/lib/loghandler.py
index d2fcb13..f0a60ee 100644
--- a/voctocore/lib/loghandler.py
+++ b/voctocore/lib/loghandler.py
@@ -22,18 +22,17 @@ class LogFormatter(logging.Formatter):
c_lvl = 31
c_mod = 31
c_msg = 31
- if self.timestamps:
- fmt = '%(asctime)s \x1b['+str(c_lvl)+'m%(levelname)8s\x1b[0m \x1b['+str(c_mod)+'m%(name)s\x1b['+str(c_msg)+'m: %(message)s\x1b[0m'
- else:
- fmt = '\x1b['+str(c_lvl)+'m%(levelname)8s\x1b[0m \x1b['+str(c_mod)+'m%(name)s\x1b['+str(c_msg)+'m: %(message)s\x1b[0m'
+
+ fmt = '\x1b['+str(c_lvl)+'m%(levelname)8s\x1b[0m \x1b['+str(c_mod)+'m%(name)s\x1b['+str(c_msg)+'m: %(message)s\x1b[0m'
else:
- if self.timestamps:
- fmt = '%(asctime)s %(levelname)8s %(name)s: %(message)s'
- else:
- fmt = '%(levelname)8s %(name)s: %(message)s'
+ fmt = '%(levelname)8s %(name)s: %(message)s'
+
+ if self.timestamps:
+ fmt = '%(asctime)s '+fmt
if not 'asctime' in record.__dict__:
record.__dict__['asctime']=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(record.__dict__['created']))
+
return fmt % record.__dict__