from loguru import logger # 根据名称注册多个 logger def register_logger(bind_name, file_path): logger.add( file_path, format="{time:YYYY-MM-DD HH:mm:ss} {level} {message}", filter=lambda record: record["extra"].get("name") == bind_name, ) new_logger = logger.bind(name=bind_name) return new_logger