Do not load logs if use_logs is false
This commit is contained in:
parent
135ef1b364
commit
7538093a07
1 changed files with 11 additions and 4 deletions
|
@ -61,12 +61,12 @@ class Logger(object):
|
||||||
self.fds[room] = self.check_and_create_log_dir(room)
|
self.fds[room] = self.check_and_create_log_dir(room)
|
||||||
log.debug('Log handle for %s re-created', 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
|
Check that the directory where we want to log the messages
|
||||||
exists. if not, create it
|
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
|
return
|
||||||
try:
|
try:
|
||||||
makedirs(log_dir)
|
makedirs(log_dir)
|
||||||
|
@ -74,7 +74,9 @@ class Logger(object):
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
log.error('Unable to create the log dir', exc_info=True)
|
log.error('Unable to create the log dir', exc_info=True)
|
||||||
pass
|
return
|
||||||
|
if not open_fd:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
fd = open(os.path.join(log_dir, room), 'a')
|
fd = open(os.path.join(log_dir, room), 'a')
|
||||||
self.fds[room] = fd
|
self.fds[room] = fd
|
||||||
|
@ -83,7 +85,6 @@ class Logger(object):
|
||||||
log.error('Unable to open the log file (%s)',
|
log.error('Unable to open the log file (%s)',
|
||||||
os.path.join(log_dir, room),
|
os.path.join(log_dir, room),
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
return
|
|
||||||
|
|
||||||
def get_logs(self, jid, nb=10):
|
def get_logs(self, jid, nb=10):
|
||||||
"""
|
"""
|
||||||
|
@ -92,8 +93,14 @@ class Logger(object):
|
||||||
if config.get_by_tabname('load_log', 10, jid) <= 0:
|
if config.get_by_tabname('load_log', 10, jid) <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if config.get_by_tabname('use_log', 'true', jid) == 'false':
|
||||||
|
return
|
||||||
|
|
||||||
if nb <= 0:
|
if nb <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.check_and_create_log_dir(jid, open_fd=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fd = open(os.path.join(log_dir, jid), 'rb')
|
fd = open(os.path.join(log_dir, jid), 'rb')
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue