SessionLogHandler
Base classes
| Name |
Children |
Inherits |
Handler logging Handler instances dispatch logging events to specific destinations. |
|
|
⋔ Inheritance diagram
graph TD
2619506680["log.SessionLogHandler"]
3558112998["logging.Handler"]
1327216795["logging.Filterer"]
2751680898["builtins.object"]
3558112998 --> 2619506680
1327216795 --> 3558112998
2751680898 --> 1327216795
🛈 DocStrings
Bases: Handler
Captures logs for display in chat session.
Source code in src/slashed/log.py
| class SessionLogHandler(logging.Handler):
"""Captures logs for display in chat session."""
def __init__(self, output_writer: OutputWriter) -> None:
super().__init__()
self.output_writer = output_writer
self.setFormatter(logging.Formatter("📝 [%(levelname)s] %(message)s"))
self._tasks: WeakSet[asyncio.Task[None]] = WeakSet()
def emit(self, record: logging.LogRecord) -> None:
try:
msg = self.format(record)
task = asyncio.create_task(self.output_writer.print(msg))
self._tasks.add(task)
task.add_done_callback(self._tasks.discard)
except Exception: # noqa: BLE001
self.handleError(record)
async def wait_for_tasks(self) -> None:
"""Wait for all pending log output tasks to complete."""
if self._tasks:
await asyncio.gather(*self._tasks, return_exceptions=True)
|
wait_for_tasks
async
Wait for all pending log output tasks to complete.
Source code in src/slashed/log.py
| async def wait_for_tasks(self) -> None:
"""Wait for all pending log output tasks to complete."""
if self._tasks:
await asyncio.gather(*self._tasks, return_exceptions=True)
|
:fa-brands-github: Show source on GitHub