home · contact · privacy
Move LogScope.RAW file logging into ClientTui.log.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 23 Sep 2025 15:28:30 +0000 (17:28 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 23 Sep 2025 15:28:30 +0000 (17:28 +0200)
ircplom/client_tui.py

index da454cc41f1620b0c031063a10b467cf2db07e15..39ec96db1ffdb7fa782732e3f62dd6fc10964382 100644 (file)
@@ -439,6 +439,13 @@ class ClientTui(BaseTui):
             return [m.window(scope)]
         return super()._log_target_wins(**kwargs)
 
+    def log(self, msg: str, **kwargs) -> tuple[tuple[int, ...], str]:
+        win_ids, logged_msg = super().log(msg, **kwargs)
+        if kwargs.get('scope', None) == _LogScope.RAW:
+            with open(f'{kwargs["client_id"]}.log', 'a', encoding='utf8') as f:
+                f.write(f'{logged_msg}\n')
+        return win_ids, logged_msg
+
     def for_client_do(self, client_id: str, todo: str, **kwargs) -> None:
         'Forward todo to appropriate _ClientWindowsManager.'
         if client_id not in self._client_mngrs:
@@ -545,9 +552,6 @@ class ClientKnowingTui(Client):
 
     def _log(self, msg: str, scope: _LogScope, **kwargs) -> None:
         self._client_tui_trigger('log', scope=scope, msg=msg, **kwargs)
-        if scope == _LogScope.RAW:
-            with open(f'{self.client_id}.log', 'a', encoding='utf8') as f:
-                f.write(('>' if kwargs['out'] else '<') + f' {msg}\n')
 
     def _on_update(self, *path) -> None:
         for path, value in self.db.into_endnode_updates(path):