import logging
import sys


def setup_logger() -> logging.Logger:
    logger = logging.getLogger("qingjian_cs")
    if logger.handlers:
        return logger
    logger.setLevel(logging.INFO)
    handler = logging.StreamHandler(sys.stdout)
    formatter = logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s", "%H:%M:%S")
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    # 降低 AgentScope 内部推理/格式器日志噪音，保留本项目活动日志。
    logging.getLogger("agentscope").setLevel(logging.ERROR)
    logging.getLogger("agentscope.formatter").setLevel(logging.ERROR)
    logging.getLogger("agentscope.agent").setLevel(logging.ERROR)
    logging.getLogger("_openai_formatter").setLevel(logging.ERROR)
    logging.getLogger("_react_agent").setLevel(logging.ERROR)

    return logger
