Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
cded162b6This file is pinned to the selected release. Download the original to open it in your design tool.
"""Logging configuration — plain text by default, one handler on stdout."""
from __future__ import annotations
import logging
import sys
_CONFIGURED = False
def configure_logging(level: str = "INFO") -> None:
"""Install a single stdout handler with a concise format.
Idempotent: safe to call multiple times (e.g. on --reload).
"""
global _CONFIGURED
if _CONFIGURED:
return
numeric_level = getattr(logging, level.upper(), logging.INFO)
root = logging.getLogger()
root.setLevel(numeric_level)
for handler in list(root.handlers):
root.removeHandler(handler)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(numeric_level)
handler.setFormatter(
logging.Formatter(
fmt="%(asctime)s %(levelname)-7s %(name)s :: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
)
root.addHandler(handler)
_CONFIGURED = True