xyphron / DragMusic /logging.py
taslim19
fix: Re-enable file logging to /tmp directory
359b1eb
raw
history blame contribute delete
736 Bytes
import logging
import os
from logging.handlers import RotatingFileHandler
# Ensure the /tmp directory exists
if not os.path.exists("/tmp"):
os.makedirs("/tmp")
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
datefmt="%d-%b-%y %H:%M:%S",
handlers=[
RotatingFileHandler(
"/tmp/logs.txt",
maxBytes=5000000,
backupCount=10,
),
logging.StreamHandler(),
],
)
logging.getLogger("httpx").setLevel(logging.ERROR)
logging.getLogger("pyrogram").setLevel(logging.ERROR)
logging.getLogger("pytgcalls").setLevel(logging.ERROR)
def LOGGER(name: str) -> logging.Logger:
return logging.getLogger(name)