summaryrefslogtreecommitdiff
path: root/src/logger.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/logger.py')
-rw-r--r--src/logger.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/logger.py b/src/logger.py
index 6b56738e..8b4b1d3c 100644
--- a/src/logger.py
+++ b/src/logger.py
@@ -97,7 +97,7 @@ class Logger(object):
logs = reads[-nb:]
return logs
- def log_message(self, jid, nick, msg):
+ def log_message(self, jid, nick, msg, date=None):
"""
log the message in the appropriate jid's file
"""
@@ -109,10 +109,14 @@ class Logger(object):
return
try:
msg = clean_text(msg)
+ if date is None:
+ str_time = datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')
+ else:
+ str_time = date.strftime('%d-%m-%y [%H:%M:%S] ')
if nick:
- fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+nick+': '+msg+'\n')
+ fd.write(''.join((str_time, nick, ': ', msg, '\n')))
else:
- fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+'* '+msg+'\n')
+ fd.write(''.join((str_time, '* ', msg, '\n')))
except IOError:
pass
else: