Move logging_config to game.

This isn't unique to the UI, the UI is just the current caller.
This commit is contained in:
Dan Albert
2022-09-03 11:34:11 -07:00
parent 0c5e548892
commit 1717bc98cb
2 changed files with 1 additions and 3 deletions

22
game/logging_config.py Normal file
View File

@@ -0,0 +1,22 @@
"""Logging APIs."""
import logging
import logging.config
import os
from pathlib import Path
import yaml
def init_logging(version: str) -> None:
"""Initializes the logging configuration."""
if not os.path.isdir("./logs"):
os.mkdir("logs")
resources = Path("resources")
log_config = resources / "default_logging.yaml"
if (custom_log_config := resources / "logging.yaml").exists():
log_config = custom_log_config
with log_config.open() as log_file:
logging.config.dictConfig(yaml.safe_load(log_file))
logging.info(f"DCS Liberation {version}")