summaryrefslogtreecommitdiff
path: root/poezio/logger.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-31 23:14:39 +0200
committermathieui <mathieui@mathieui.net>2021-04-02 22:22:30 +0200
commitf56811d5466d4b23f6bfc71b88cb6cdbc4090e29 (patch)
tree506778c58581b0f37b690fcd4b98fc0e94d3c3c3 /poezio/logger.py
parentbbc22fc8bc99be8c84272efa591487a33ef12fc4 (diff)
downloadpoezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.tar.gz
poezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.tar.bz2
poezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.tar.xz
poezio-f56811d5466d4b23f6bfc71b88cb6cdbc4090e29.zip
logging: Remove the "typ" passing when adding or logging messages
Diffstat (limited to 'poezio/logger.py')
-rw-r--r--poezio/logger.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/poezio/logger.py b/poezio/logger.py
index b55e579d..a5916050 100644
--- a/poezio/logger.py
+++ b/poezio/logger.py
@@ -11,13 +11,14 @@ conversations and roster changes
import mmap
import re
-from typing import List, Dict, Optional, IO, Any
+from typing import List, Dict, Optional, IO, Any, Union
from datetime import datetime
from poezio import common
from poezio.config import config
from poezio.xhtml import clean_text
from poezio.theming import dump_tuple, get_theme
+from poezio.ui.types import Message, BaseMessage, LoggableTrait
import logging
@@ -134,10 +135,7 @@ class Logger:
def log_message(self,
jid: str,
- nick: str,
- msg: str,
- date: Optional[datetime] = None,
- typ: int = 1) -> bool:
+ msg: Union[BaseMessage, Message]) -> bool:
"""
log the message in the appropriate jid's file
type:
@@ -147,7 +145,16 @@ class Logger:
"""
if not config.get_by_tabname('use_log', jid):
return True
- logged_msg = build_log_message(nick, msg, date=date, typ=typ)
+ if not isinstance(msg, LoggableTrait):
+ return True
+ date = msg.time
+ txt = msg.txt
+ typ = 2
+ nick = ''
+ if isinstance(msg, Message):
+ nick = msg.nickname or ''
+ typ = 1
+ logged_msg = build_log_message(nick, txt, date=date, typ=typ)
if not logged_msg:
return True
jid = str(jid).replace('/', '\\')