mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix double logging.
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.
This commit is contained in:
parent
1d7f1082ea
commit
6bfb8cf2fd
@ -1,26 +1,22 @@
|
||||
"""Logging APIs."""
|
||||
import logging
|
||||
import os
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
|
||||
def init_logging(version_string):
|
||||
def init_logging(version: str) -> None:
|
||||
"""Initializes the logging configuration."""
|
||||
if not os.path.isdir("./logs"):
|
||||
os.mkdir("logs")
|
||||
|
||||
logging.basicConfig(level="DEBUG")
|
||||
fmt = "%(asctime)s :: %(levelname)s :: %(message)s"
|
||||
logging.basicConfig(level=logging.DEBUG, format=fmt)
|
||||
logger = logging.getLogger()
|
||||
|
||||
formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s')
|
||||
|
||||
handler = RotatingFileHandler('./logs/liberation.log', 'a', 5000000, 1)
|
||||
handler.setLevel(logging.INFO)
|
||||
handler.setFormatter(formatter)
|
||||
handler.setFormatter(logging.Formatter(fmt))
|
||||
|
||||
stream_handler = logging.StreamHandler()
|
||||
stream_handler.setLevel(logging.DEBUG)
|
||||
stream_handler.setFormatter(formatter)
|
||||
|
||||
logger.addHandler(stream_handler)
|
||||
logger.addHandler(handler)
|
||||
|
||||
logger.info("DCS Liberation {}".format(version_string))
|
||||
logger.info(f"DCS Liberation {version}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user