summaryrefslogtreecommitdiff
path: root/src/logging.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-03-18 19:43:44 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-03-18 19:43:44 +0000
commitfc82ad6b3d3aa917fd70edfb73278356cce41ad4 (patch)
treee6c6b2314e86f7952981b94236b8cac7c5101b90 /src/logging.py
parent5d7bb0fd6751e28320dad715e98bfe8112ee71f6 (diff)
downloadpoezio-fc82ad6b3d3aa917fd70edfb73278356cce41ad4.tar.gz
poezio-fc82ad6b3d3aa917fd70edfb73278356cce41ad4.tar.bz2
poezio-fc82ad6b3d3aa917fd70edfb73278356cce41ad4.tar.xz
poezio-fc82ad6b3d3aa917fd70edfb73278356cce41ad4.zip
fixed #1186
Diffstat (limited to 'src/logging.py')
-rw-r--r--src/logging.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/logging.py b/src/logging.py
index bb22e5c9..aa466348 100644
--- a/src/logging.py
+++ b/src/logging.py
@@ -18,8 +18,15 @@
# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
import sys
+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/'
+
class Logger(object):
"""
Appends things to files. Error/information/warning logs
@@ -50,4 +57,18 @@ class Logger(object):
fd.close()
sys.exit(-1)
+ def message(self, room, nick, msg):
+ """
+ log the message in the appropriate room
+ """
+ if config.get('use_log', 'false') == 'false':
+ return
+ dir = CONFIG_PATH+'logs/'
+ try:
+ makedirs(dir)
+ except:pass
+ fd = open(dir+room, 'a')
+ fd.write(datetime.now().strftime('%d-%m-%y [%H:%M:%S] ')+nick+': '+msg+'\n')
+ fd.close()
+
logger = Logger()