summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-02-21 21:00:23 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-02-21 21:00:23 +0100
commitcc74576c9f5a77128db99468a8432c7de8100302 (patch)
treee098d4ea14540dae9a2f177246a6f37a810ade7e /src
parent0d6ec6c5d3ddc42b445fae2c703e91b5870ec624 (diff)
downloadpoezio-cc74576c9f5a77128db99468a8432c7de8100302.tar.gz
poezio-cc74576c9f5a77128db99468a8432c7de8100302.tar.bz2
poezio-cc74576c9f5a77128db99468a8432c7de8100302.tar.xz
poezio-cc74576c9f5a77128db99468a8432c7de8100302.zip
Avoid crash when write to log file fails
Diffstat (limited to 'src')
-rw-r--r--src/logger.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/logger.py b/src/logger.py
index d2a00eaa..4078c46a 100644
--- a/src/logger.py
+++ b/src/logger.py
@@ -69,10 +69,14 @@ class Logger(object):
fd = self.check_and_create_log_dir(jid)
if not fd:
return
- if nick:
- fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+nick+': '+msg+'\n')
+ try:
+ if nick:
+ fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+nick+': '+msg+'\n')
+ else:
+ fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+'* '+msg+'\n')
+ except IOError:
+ pass
else:
- fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+'* '+msg+'\n')
- fd.flush() # TODO do something better here?
+ fd.flush() # TODO do something better here?
logger = Logger()