Fix the per-tab options on logs

This commit is contained in:
mathieui 2012-12-16 13:42:22 +01:00
parent 344e8c8d6c
commit cb900858a0

View file

@ -49,8 +49,8 @@ class Logger(object):
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('use_log', 'false') == 'false': if config.get_by_tabname('use_log', 'false', room) == 'false':
return None return
directory = os.path.join(DATA_HOME, 'logs') directory = os.path.join(DATA_HOME, 'logs')
try: try:
makedirs(directory) makedirs(directory)
@ -61,13 +61,13 @@ class Logger(object):
self.fds[room] = fd self.fds[room] = fd
return fd return fd
except IOError: except IOError:
return None return
def get_logs(self, jid, nb=10): def get_logs(self, jid, nb=10):
""" """
Get the log history for the given jid Get the log history for the given jid
""" """
if config.get_by_tabname('use_log', 'false', jid) == 'false': if config.get_by_tabname('load_log', 10, jid) <= 0:
return return
if nb <= 0: if nb <= 0:
@ -83,9 +83,11 @@ class Logger(object):
pos = fd.seek(0, 2) pos = fd.seek(0, 2)
reads = fd.readlines() reads = fd.readlines()
while len(reads) < nb + 1: while len(reads) < nb + 1:
if pos == 0:
break
pos -= 100 pos -= 100
if pos < 0: if pos < 0:
break pos = 0
fd.seek(pos) fd.seek(pos)
try: try:
reads = fd.readlines() reads = fd.readlines()