"""web_gui_pkg.logger - 内部日志输出。 _wg_log: 统一 web_gui 内部错误日志出口;失败兜底 stdout。 启动横幅和中断消息走 stdout(属于交互/CLI 输出)。 """ from __future__ import annotations import logging as _logging _LOGGER = _logging.getLogger("gui.web_gui") def _wg_log(msg: str, level: str = "INFO") -> None: """统一 web_gui 内部错误日志出口;失败兜底 stdout。""" try: lv = str(level or "INFO").upper() if lv == "ERROR": _LOGGER.error(str(msg)) elif lv == "WARNING": _LOGGER.warning(str(msg)) elif lv == "DEBUG": _LOGGER.debug(str(msg)) else: _LOGGER.info(str(msg)) except Exception: try: print(str(msg)) except Exception: pass