mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Calling logging.basicConfig creates a stream handler for the root logger, and then we were adding our own with a different formatter. Pass the format string to basicConfig so we don't need to add our own duplicate stream handler.
23 lines
632 B
Python
23 lines
632 B
Python
"""Logging APIs."""
|
|
import logging
|
|
import os
|
|
from logging.handlers import RotatingFileHandler
|
|
|
|
|
|
def init_logging(version: str) -> None:
|
|
"""Initializes the logging configuration."""
|
|
if not os.path.isdir("./logs"):
|
|
os.mkdir("logs")
|
|
|
|
fmt = "%(asctime)s :: %(levelname)s :: %(message)s"
|
|
logging.basicConfig(level=logging.DEBUG, format=fmt)
|
|
logger = logging.getLogger()
|
|
|
|
handler = RotatingFileHandler('./logs/liberation.log', 'a', 5000000, 1)
|
|
handler.setLevel(logging.INFO)
|
|
handler.setFormatter(logging.Formatter(fmt))
|
|
|
|
logger.addHandler(handler)
|
|
|
|
logger.info(f"DCS Liberation {version}")
|