summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-01 22:01:09 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-01 22:01:09 +0000
commit432bab0b6ba56db5956b823a297347494f09cbd7 (patch)
tree3875743bea7d5c9dd2af289757a9bfc3db74cc36 /src
parent2b19ec1cff9435dc5608def7d1ef9050f66763ac (diff)
downloadpoezio-432bab0b6ba56db5956b823a297347494f09cbd7.tar.gz
poezio-432bab0b6ba56db5956b823a297347494f09cbd7.tar.bz2
poezio-432bab0b6ba56db5956b823a297347494f09cbd7.tar.xz
poezio-432bab0b6ba56db5956b823a297347494f09cbd7.zip
logs are now xdg compliant, fixed #1520
Diffstat (limited to 'src')
-rw-r--r--src/logging.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/logging.py b/src/logging.py
index 42a82760..a3321cdf 100644
--- a/src/logging.py
+++ b/src/logging.py
@@ -22,10 +22,10 @@ from os import environ, makedirs
from datetime import datetime
from config import config
-CONFIG_HOME = environ.get("XDG_CONFIG_HOME")
-if not CONFIG_HOME:
- CONFIG_HOME = environ.get('HOME')+'/.config'
-CONFIG_PATH = CONFIG_HOME + '/poezio/'
+DATA_HOME = config.get('log_dir', environ.get("XDG_DATA_HOME"))
+if not DATA_HOME:
+ DATA_HOME = environ.get('HOME')+'/.local/share'
+DATA_PATH = DATA_HOME + '/poezio/'
class Logger(object):
"""
@@ -63,11 +63,15 @@ class Logger(object):
"""
if config.get('use_log', 'false') == 'false':
return
- dir = CONFIG_PATH+'logs/'
+ dir = DATA_PATH+'logs/'
try:
makedirs(dir)
- except:pass
- fd = open(dir+room, 'a')
+ except OSError:
+ pass
+ try:
+ fd = open(dir+room, 'a')
+ except IOError:
+ return
if nick:
fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+nick.encode('utf-8')+': '+msg.encode('utf-8')+'\n')
else: