File size: 348 Bytes
65d3d39 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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
|