home · contact · privacy
Add basic time display to all log lines.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 7 Aug 2025 02:35:07 +0000 (04:35 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 7 Aug 2025 02:35:07 +0000 (04:35 +0200)
ircplom/events.py

index 6734e60f967f8faeb43e3f595c29a336f135ae53..b143b7812005e615d3a664c98aa5e65740737975 100644 (file)
@@ -1,6 +1,7 @@
 'Event system with event loop.'
 from abc import abstractmethod, ABC
 from dataclasses import dataclass
+from datetime import datetime
 from queue import SimpleQueue, Empty as QueueEmpty
 from threading import Thread
 from typing import Any, Callable, Iterator, Literal, Self
@@ -117,7 +118,8 @@ class Logger:
     def add(self, msg: str, prefix: str = _LOG_PREFIX_DEFAULT, **kwargs
             ) -> None:
         'Add msg to log.'
-        self._to_call(f'{prefix}{msg}', **kwargs)
+        time = str(datetime.now())[11:19]
+        self._to_call(f'{time} {prefix}{msg}', **kwargs)
 
     def alert(self, msg: str, **kwargs) -> None:
         'Add msg prefixed with _LOG_PREFIX_ALERT to log.'