diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-01-12 18:34:04 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-01-12 18:34:04 +0100 |
commit | ce1fc18e104c9ed963347c50c48a7e40f755027e (patch) | |
tree | 11e35a47d8b8001503174920fa567584a7b22a6a | |
parent | 22ad96e7aa06e03d380f35d66212cea713dff0f2 (diff) | |
download | poezio-ce1fc18e104c9ed963347c50c48a7e40f755027e.tar.gz poezio-ce1fc18e104c9ed963347c50c48a7e40f755027e.tar.bz2 poezio-ce1fc18e104c9ed963347c50c48a7e40f755027e.tar.xz poezio-ce1fc18e104c9ed963347c50c48a7e40f755027e.zip |
Log messages from normal and private conversations as well
-rw-r--r-- | src/core.py | 2 | ||||
-rw-r--r-- | src/logger.py | 16 | ||||
-rw-r--r-- | src/room.py | 2 | ||||
-rw-r--r-- | src/tabs.py | 3 |
4 files changed, 14 insertions, 9 deletions
diff --git a/src/core.py b/src/core.py index 104a653f..e266fc1e 100644 --- a/src/core.py +++ b/src/core.py @@ -519,6 +519,7 @@ class Core(object): room.add_message(body, time=None, nickname=nick_from, colorized=False, forced_user=self.get_room_by_name(room_from).get_user_by_name(nick_from)) + logger.log_message(jid.full.replace('/', '\\'), nick_from, body) self.refresh_window() self.doupdate() @@ -548,6 +549,7 @@ class Core(object): else: remote_nick = jid.user conversation.get_room().add_message(body, None, remote_nick, False, theme.COLOR_REMOTE_USER) + logger.log_message(jid.bare, remote_nick, body) if self.current_tab() is not conversation: conversation.set_color_state(theme.COLOR_TAB_PRIVATE) self.refresh_window() diff --git a/src/logger.py b/src/logger.py index 991187a0..d2a00eaa 100644 --- a/src/logger.py +++ b/src/logger.py @@ -34,10 +34,10 @@ class Logger(object): def __init__(self): self.logfile = config.get('logfile', 'logs') # a dict of 'groupchatname': file-object (opened) - self.groupchat_fds = dict() + self.fds = dict() def __del__(self): - for opened_file in self.groupchat_fds.values(): + for opened_file in self.fds.values(): opened_file.close() def check_and_create_log_dir(self, room): @@ -54,19 +54,19 @@ class Logger(object): pass try: fd = open(os.path.join(directory, room), 'a') - self.groupchat_fds[room] = fd + self.fds[room] = fd return fd except IOError: return None - def groupchat(self, room, nick, msg): + def log_message(self, jid, nick, msg): """ - log the message in the appropriate room's file + log the message in the appropriate jid's file """ - if room in self.groupchat_fds.keys(): - fd = self.groupchat_fds[room] + if jid in self.fds.keys(): + fd = self.fds[jid] else: - fd = self.check_and_create_log_dir(room) + fd = self.check_and_create_log_dir(jid) if not fd: return if nick: diff --git a/src/room.py b/src/room.py index 0c34b445..1613ecee 100644 --- a/src/room.py +++ b/src/room.py @@ -52,7 +52,7 @@ class Room(TextBuffer): to be """ if time is None and self.joined: # don't log the history messages - logger.groupchat(self.name, nickname, txt) + logger.log_message(self.name, nickname, txt) def do_highlight(self, txt, time, nickname): """ diff --git a/src/tabs.py b/src/tabs.py index 92b6f9c5..1c0e4d93 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -43,6 +43,7 @@ from sleekxmpp.xmlstream.stanzabase import JID from config import config from roster import RosterGroup, roster from contact import Contact, Resource +from logger import logger import multiuserchat as muc class Tab(object): @@ -655,6 +656,7 @@ class PrivateTab(ChatTab): def command_say(self, line): muc.send_private_message(self.core.xmpp, self.get_name(), line) self.core.add_message_to_text_buffer(self.get_room(), line, None, self.get_room().own_nick) + logger.log_message(self.get_name().replace('/', '\\'), self.get_room().own_nick, line) def command_unquery(self, arg): """ @@ -1034,6 +1036,7 @@ class ConversationTab(ChatTab): def command_say(self, line): muc.send_private_message(self.core.xmpp, self.get_name(), line) self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick) + logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line) def command_unquery(self, arg): self.core.close_tab() |