diff options
author | mathieui <mathieui@mathieui.net> | 2014-04-06 17:26:33 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-04-06 17:26:33 +0200 |
commit | e000466ab8950fd91ef3723e60cc9397262ca527 (patch) | |
tree | 9f7af41f102d468e51786eb10ae4b0ba4b863c25 /src | |
parent | fe070163228fba339445483883a05d0178f321cd (diff) | |
download | poezio-e000466ab8950fd91ef3723e60cc9397262ca527.tar.gz poezio-e000466ab8950fd91ef3723e60cc9397262ca527.tar.bz2 poezio-e000466ab8950fd91ef3723e60cc9397262ca527.tar.xz poezio-e000466ab8950fd91ef3723e60cc9397262ca527.zip |
Do not instantiate the message logger at module level
.
Diffstat (limited to 'src')
-rw-r--r-- | src/logger.py | 22 | ||||
-rw-r--r-- | src/poezio.py | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/logger.py b/src/logger.py index 6248cfdf..e758bdc0 100644 --- a/src/logger.py +++ b/src/logger.py @@ -5,6 +5,11 @@ # Poezio is free software: you can redistribute it and/or modify # it under the terms of the zlib license. See the COPYING file. +""" +The logger module that handles logging of the poezio +conversations and roster changes +""" + import mmap import os import re @@ -24,8 +29,12 @@ from config import LOG_DIR log_dir = os.path.join(LOG_DIR, 'logs') -message_log_re = re.compile('MR (\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})Z (\d+) <([^ ]+)> (.*)') -info_log_re = re.compile('MI (\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})Z (\d+) (.*)') +message_log_re = re.compile(r'MR (\d{4})(\d{2})(\d{2})T' + r'(\d{2}):(\d{2}):(\d{2})Z ' + r'(\d+) <([^ ]+)> (.*)') +info_log_re = re.compile(r'MI (\d{4})(\d{2})(\d{2})T' + r'(\d{2}):(\d{2}):(\d{2})Z ' + r'(\d+) (.*)') def parse_message_line(msg): if re.match(message_log_re, msg): @@ -153,7 +162,7 @@ class Logger(object): continue tup = parse_message_line(lines[idx]) idx += 1 - if not tup or 7 > len(tup) > 10 : # skip + if not tup or 7 > len(tup) > 10: # skip log.debug('format? %s', tup) continue time = [int(i) for index, i in enumerate(tup) if index < 6] @@ -264,4 +273,9 @@ class Logger(object): return False return True -logger = Logger() +def create_logger(): + "Create the global logger object" + global logger + logger = Logger() + +logger = None diff --git a/src/poezio.py b/src/poezio.py index 99831896..219a2279 100644 --- a/src/poezio.py +++ b/src/poezio.py @@ -33,6 +33,8 @@ def main(): from config import options + import logger + logger.create_logger() import core |