diff options
Diffstat (limited to 'src/logger.py')
-rw-r--r-- | src/logger.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/logger.py b/src/logger.py index 4858e116..8dfb25ea 100644 --- a/src/logger.py +++ b/src/logger.py @@ -63,6 +63,25 @@ class Logger(object): except IOError: return None + def get_logs(self, jid, nb=200): + """ + Get the log history for the given jid + """ + if nb <= 0: + return None + directory = os.path.join(DATA_HOME, 'logs') + try: + fd = open(os.path.join(directory, jid), 'r') + except: + return None + else: + if not fd: + return None + + logs = fd.readlines() + fd.close() + return logs[-nb:] + def log_message(self, jid, nick, msg): """ log the message in the appropriate jid's file |