| 1234567891011121314151617181920212223 |
- import logging
- # 内部持有一个 logger 实例,默认是 Root Logger(防止在没初始化前报错)
- _active_logger = logging.getLogger()
- def set_active_logger(logger: logging.Logger):
- """供外部日志配置工具调用,用于重定向所有宏的输出"""
- global _active_logger
- _active_logger = logger
- # --- 宏定义 (调用签名完全保持原样) ---
- def VSC_INFO(tag, message, *args):
- _active_logger.info(f"[{tag}] {message}", *args)
- def VSC_DEBUG(tag, message, *args):
- _active_logger.debug(f"[{tag}] {message}", *args)
- def VSC_WARN(tag, message, *args):
- _active_logger.warning(f"[{tag}] {message}", *args)
- def VSC_ERROR(tag, message, *args):
- _active_logger.error(f"[{tag}] {message}", *args)
|