diff options
author | mathieui <mathieui@mathieui.net> | 2013-08-04 11:19:43 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-08-04 11:21:28 +0200 |
commit | 7538093a07bbe65ed17a1c305a8fa98bccac9d95 (patch) | |
tree | 4aeedf306c80b2af3cb733abf4b85a9073481f81 | |
parent | 135ef1b364c04fc4b38702faf84e8f42e7ac49d1 (diff) | |
download | poezio-7538093a07bbe65ed17a1c305a8fa98bccac9d95.tar.gz poezio-7538093a07bbe65ed17a1c305a8fa98bccac9d95.tar.bz2 poezio-7538093a07bbe65ed17a1c305a8fa98bccac9d95.tar.xz poezio-7538093a07bbe65ed17a1c305a8fa98bccac9d95.zip |
Do not load logs if use_logs is false
-rw-r--r-- | src/logger.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/logger.py b/src/logger.py index 00f54f6e..79d5296d 100644 --- a/src/logger.py +++ b/src/logger.py @@ -61,12 +61,12 @@ class Logger(object): self.fds[room] = self.check_and_create_log_dir(room) log.debug('Log handle for %s re-created', room) - def check_and_create_log_dir(self, room): + def check_and_create_log_dir(self, room, open_fd=True): """ Check that the directory where we want to log the messages exists. if not, create it """ - if config.get_by_tabname('use_log', 'false', room) == 'false': + if config.get_by_tabname('use_log', 'true', room) == 'false': return try: makedirs(log_dir) @@ -74,7 +74,9 @@ class Logger(object): pass except: log.error('Unable to create the log dir', exc_info=True) - pass + return + if not open_fd: + return try: fd = open(os.path.join(log_dir, room), 'a') self.fds[room] = fd @@ -83,7 +85,6 @@ class Logger(object): log.error('Unable to open the log file (%s)', os.path.join(log_dir, room), exc_info=True) - return def get_logs(self, jid, nb=10): """ @@ -92,8 +93,14 @@ class Logger(object): if config.get_by_tabname('load_log', 10, jid) <= 0: return + if config.get_by_tabname('use_log', 'true', jid) == 'false': + return + if nb <= 0: return + + self.check_and_create_log_dir(jid, open_fd=False) + try: fd = open(os.path.join(log_dir, jid), 'rb') except: |