Files
add-todo-all/examples/todo_skill/scripts/util/logging_config.py
2026-09-09 10:29:02 +08:00

30 lines
883 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""日志:直接用 stdlib logging(真实模板用 jiangchang_skill_core.unified_logging)。
为保持与模板 ``from util.logging_config import get_skill_logger, setup_skill_logging``
一致的调用面,本 demo 提供同名薄封装。
"""
from __future__ import annotations
import logging
from util.constants import LOG_LOGGER_NAME
_configured = False
def setup_skill_logging(skill_slug: str, logger_name: str) -> None:
global _configured
if _configured:
return
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(name)s: %(message)s"))
logger = logging.getLogger(logger_name)
logger.setLevel(logging.INFO)
if not logger.handlers:
logger.addHandler(handler)
_configured = True
def get_skill_logger() -> logging.Logger:
return logging.getLogger(LOG_LOGGER_NAME)