feat: add TUI-safe logging mode that disables RichHandler
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,21 @@ def setup_logging(
|
||||
)
|
||||
|
||||
|
||||
def setup_logging_for_tui() -> None:
|
||||
"""Reconfigure logging for Textual TUI mode.
|
||||
|
||||
Removes the RichHandler (which writes to stdout and corrupts the TUI)
|
||||
while preserving any file handlers. Call this from the Textual App's
|
||||
on_mount() before any agent work begins.
|
||||
"""
|
||||
from rich.logging import RichHandler
|
||||
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.handlers = [
|
||||
h for h in root_logger.handlers if not isinstance(h, RichHandler)
|
||||
]
|
||||
|
||||
|
||||
def get_logger(name: str) -> structlog.stdlib.BoundLogger:
|
||||
"""Get a named structlog logger.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user