StarfallBot/starfall/log.py

21 lines
681 B
Python

import logging
import werkzeug
from rich.logging import RichHandler
class Log:
def __init__(self) -> None:
handler = RichHandler(level=logging.DEBUG, rich_tracebacks=True)
logging.basicConfig(
level=logging.DEBUG,
format="%(message)s [%(name)s]",
datefmt="[%Y-%m-%d %H:%M:%S]",
handlers=[handler],
)
# NOTE: pyright's reportPrivateUsage is suppressed here.
# We disable ANSI terminal codes from being added to Werkzeug (Flask) logs;
# RichHandler already handles all the fancy color stuff.
werkzeug.serving._log_add_style = False # pyright: ignore[reportPrivateUsage]