mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix logging.
Same problem as last time: we were logging during initialization before the log handlers could be initialized.
This commit is contained in:
parent
f5047fc0cc
commit
b34de70fc7
@ -911,7 +911,7 @@ CARRIER_TAKEOFF_BAN: List[Type[FlyingType]] = [
|
|||||||
Units separated by country.
|
Units separated by country.
|
||||||
country : DCS Country name
|
country : DCS Country name
|
||||||
"""
|
"""
|
||||||
FACTIONS: Dict[str, Faction] = FactionLoader.load_factions()
|
FACTIONS = FactionLoader()
|
||||||
|
|
||||||
CARRIER_TYPE_BY_PLANE = {
|
CARRIER_TYPE_BY_PLANE = {
|
||||||
FA_18C_hornet: CVN_74_John_C__Stennis,
|
FA_18C_hornet: CVN_74_John_C__Stennis,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, Type
|
from typing import Dict, Iterator, Optional, Type
|
||||||
|
|
||||||
from game.factions.faction import Faction
|
from game.factions.faction import Faction
|
||||||
|
|
||||||
@ -10,6 +10,17 @@ FACTION_DIRECTORY = Path("./resources/factions/")
|
|||||||
|
|
||||||
|
|
||||||
class FactionLoader:
|
class FactionLoader:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self._factions: Optional[Dict[str, Faction]] = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def factions(self) -> Dict[str, Faction]:
|
||||||
|
self.initialize()
|
||||||
|
return self._factions
|
||||||
|
|
||||||
|
def initialize(self) -> None:
|
||||||
|
if self._factions is None:
|
||||||
|
self._factions = self.load_factions()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_factions(cls: Type[FactionLoader]) -> Dict[str, Faction]:
|
def load_factions(cls: Type[FactionLoader]) -> Dict[str, Faction]:
|
||||||
@ -26,3 +37,9 @@ class FactionLoader:
|
|||||||
logging.exception(f"Unable to load faction : {f}")
|
logging.exception(f"Unable to load faction : {f}")
|
||||||
|
|
||||||
return factions
|
return factions
|
||||||
|
|
||||||
|
def __getitem__(self, name: str) -> Faction:
|
||||||
|
return self.factions[name]
|
||||||
|
|
||||||
|
def __iter__(self) -> Iterator[str]:
|
||||||
|
return iter(self.factions.keys())
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from PySide2 import QtWidgets
|
|||||||
from PySide2.QtGui import QPixmap
|
from PySide2.QtGui import QPixmap
|
||||||
from PySide2.QtWidgets import QApplication, QSplashScreen
|
from PySide2.QtWidgets import QApplication, QSplashScreen
|
||||||
|
|
||||||
from game import persistency
|
from game import db, persistency
|
||||||
from qt_ui import (
|
from qt_ui import (
|
||||||
liberation_install,
|
liberation_install,
|
||||||
liberation_theme,
|
liberation_theme,
|
||||||
@ -23,6 +23,8 @@ from qt_ui.windows.preferences.QLiberationFirstStartWindow import \
|
|||||||
logging_config.init_logging(uiconstants.VERSION_STRING)
|
logging_config.init_logging(uiconstants.VERSION_STRING)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Load eagerly to catch errors early.
|
||||||
|
db.FACTIONS.initialize()
|
||||||
|
|
||||||
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" # Potential fix for 4K screens
|
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" # Potential fix for 4K screens
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user