PagerMaid-Pyro/pagermaid/utils/_log.py
xtaodada a941308d17
Some checks failed
Docker Dev Build / docker build and publish (push) Failing after 13s
Docker Build / docker build and publish (push) Failing after 11s
🔖 Update to v1.5.0
这是一项破坏性变更,目录结构进行了重组,无核心功能变化
2024-09-28 22:01:40 +08:00

30 lines
895 B
Python

import logging
from coloredlogs import ColoredFormatter
from pagermaid.config import Config
logs = logging.getLogger("pagermaid")
logging_format = "%(levelname)s [%(asctime)s] [%(name)s] %(message)s"
logging_handler = logging.StreamHandler()
logging_handler.setFormatter(ColoredFormatter(logging_format))
file_handler = logging.FileHandler(
filename="data/pagermaid.log.txt", mode="w", encoding="utf-8"
)
file_handler.setFormatter(logging.Formatter(logging_format))
logging.basicConfig(
level=logging.DEBUG if Config.DEBUG else logging.INFO,
handlers=[logging_handler, file_handler],
)
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG if Config.DEBUG else logging.CRITICAL)
pyro_logger = logging.getLogger("pyrogram")
pyro_logger.setLevel(logging.INFO if Config.DEBUG else logging.CRITICAL)
logs.setLevel(logging.DEBUG if Config.DEBUG else logging.INFO)