Files
mcp-server/common/logging.py
T
Claude 5c7dcf57cc feat: structured DEBUG/INFO logging via loguru
- common/logging.py: improve format to timestamp|LEVEL|module:func:line - message
- core/ layer: DEBUG log every subprocess invocation (cmd, rc, byte counts),
  JSON load/dump events, parsed application_id. ERROR log on failures.
- tools/ layer: DEBUG log every public tool entry with key parameters,
  INFO log on business outcomes (saved/submitted/killed/...).
- New tests/unit/test_logging.py: capture loguru output via in-memory sink
  and assert DEBUG + INFO messages are emitted for representative flows.
2026-06-24 15:02:54 +08:00

30 lines
812 B
Python

# coding=utf-8
"""
@Time :2026/6/24
@Author :tao.chen
Process-wide loguru configuration. Import `logger` from here in every
module instead of instantiating new loggers.
Levels used in this project:
DEBUG - entry/exit of public tools, subprocess commands, file I/O paths
INFO - business events (job submitted, status changed, connection saved)
WARNING - recoverable problems (transient YARN issues, retry-able)
ERROR - raised exceptions (caller will see the traceback)
"""
import sys
from loguru import logger
logger.remove()
logger.add(
sys.stderr,
level="DEBUG",
format=(
"<green>{time:HH:mm:ss.SSS}</green> | "
"<level>{level: <7}</level> | "
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - "
"<level>{message}</level>"
),
)