summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-06-28 16:48:38 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-06-28 16:48:38 +0200
commit01a4920bc8c9ec9cfdec8b75c46af17e46316961 (patch)
tree296d0af2f7631bd0243390b5ee6e7351f94aca08
parentfbe376b6db019adbcf32a7b869cba600c5503f8e (diff)
downloadpoezio-01a4920bc8c9ec9cfdec8b75c46af17e46316961.tar.gz
poezio-01a4920bc8c9ec9cfdec8b75c46af17e46316961.tar.bz2
poezio-01a4920bc8c9ec9cfdec8b75c46af17e46316961.tar.xz
poezio-01a4920bc8c9ec9cfdec8b75c46af17e46316961.zip
Factorise code in logger.
-rw-r--r--poezio/logger.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/poezio/logger.py b/poezio/logger.py
index 1ebd5cf4..207af0c3 100644
--- a/poezio/logger.py
+++ b/poezio/logger.py
@@ -267,14 +267,9 @@ def build_log_message(nick, msg, date=None, typ=1):
return ''
msg = clean_text(msg)
- if date is None:
- str_time = common.get_utc_time().strftime('%Y%m%dT%H:%M:%SZ')
- else:
- str_time = common.get_utc_time(date).strftime('%Y%m%dT%H:%M:%SZ')
- if typ == 1:
- prefix = 'MR'
- else:
- prefix = 'MI'
+ time = common.get_utc_time() if date is None else common.get_utc_time(date)
+ str_time = time.strftime('%Y%m%dT%H:%M:%SZ')
+ prefix = 'MR' if typ == 1 else 'MI'
lines = msg.split('\n')
first_line = lines.pop(0)
nb_lines = str(len(lines)).zfill(3)