logs are now xdg compliant, fixed #1520
This commit is contained in:
parent
2b19ec1cff
commit
432bab0b6b
3 changed files with 18 additions and 8 deletions
|
@ -8,6 +8,7 @@ http://codingteam.net/project/poezio/roadmap
|
|||
- default nickname is now $USER
|
||||
- Server on /join command can be omitted
|
||||
- /query command can now take a message in parameters
|
||||
- logs are now save in $XDG_DATA_HOME and this can be configured
|
||||
|
||||
* Poezio 0.6.1 - 13 Jun 2010
|
||||
- Enable tracebacks
|
||||
|
|
|
@ -75,9 +75,14 @@ hide_exit_join = -1
|
|||
hide_status_change = 120
|
||||
|
||||
# set to 'true' if you want to save logs of all the messages
|
||||
# in files. They will be saved in ~/.config/poezio/logs
|
||||
# in files.
|
||||
use_log = false
|
||||
|
||||
# If log_dir is not set, logs will be saved in $XDG_DATA_HOME/poezio/logs,
|
||||
# i.e. in ~/.local/share/poezio/logs. So, you should specify the directory
|
||||
# you want to use instead. This directory will be created if it doesn't exist
|
||||
log_dir =
|
||||
|
||||
# the full path to the photo (avatar) you want to use
|
||||
# it should be less than 16Ko
|
||||
# The avatar is not set by default, because it slows
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue