# test_logger.py
# from utils.logger import log
# import platform
#
# def test_logging():
#     log.info(f"当前系统: {platform.system()}")
#     try:
#         1/0
#     except:
#         log.error("除零错误", exc_info=True)
#
# if __name__ == "__main__":
#     test_logging()


# test_log_rotation.py
# from utils.logger import log
# import time
#
# def generate_large_log():
#     """快速生成超过20MB的测试日志"""
#     for i in range(10000):
#         log.info(f"测试日志填充数据... {i}" * 10)
#         time.sleep(0.001)  # 避免内存暴涨
#
# if __name__ == "__main__":
#     generate_large_log()

# 使用方法
# my_module/main_class.py
from utils.logger import log

class MainProcessor:
    def __init__(self):
        self.log = log.bind(module=self.__class__.__name__)  # 动态绑定类名

    def main(self):
        """主执行方法"""
        self.log.info("开始执行主流程")
        try:
            self._step1()
            # self._step2()
        except Exception as e:
            self.log.error("主流程执行失败", exc_info=e)
            raise

    def _step1(self):
        """子方法示例"""
        self.log.debug("执行步骤1: 初始化资源")
        # ...业务逻辑...
        resource_count = 10
        self.log.info("步骤1完成 | created={}", resource_count)

if __name__ == "__main__":
    processor = MainProcessor()
    processor.main()