Skip to content

UINotificationHandler

Base classes

Name Children Inherits
Handler
logging
Handler instances dispatch logging events to specific destinations.
  • Filterer

⋔ Inheritance diagram

graph TD
  2676611177["log.UINotificationHandler"]
  3558112998["logging.Handler"]
  1327216795["logging.Filterer"]
  2751680898["builtins.object"]
  3558112998 --> 2676611177
  1327216795 --> 3558112998
  2751680898 --> 1327216795

🛈 DocStrings

Bases: Handler

Log handler that shows messages as Textual notifications.

Source code in src/slashed/textual_adapter/log.py
class UINotificationHandler(logging.Handler):
    """Log handler that shows messages as Textual notifications."""

    def __init__(self, widget: Widget) -> None:
        super().__init__()
        self.widget = widget

    def emit(self, record: logging.LogRecord) -> None:
        try:
            # Only show debug/info as notifications
            if record.levelno <= logging.INFO:
                self.widget.notify(self.format(record))
        except Exception:  # noqa: BLE001
            self.handleError(record)

:fa-brands-github: Show source on GitHub