1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-22 11:50:28 +03:00

Add get_main_logger() method to EDMCLogging.py

This is so the decision on appname versus appcmdname is in one place.
This commit is contained in:
Athanasius 2020-09-22 15:35:42 +01:00
parent 0f3ebd6e23
commit c0b01f88ac

View File

@ -10,13 +10,14 @@ strings.
import inspect
import logging
import logging.handlers
import os
import pathlib
import tempfile
# So that any warning about accessing a protected member is only in one place.
from sys import _getframe as getframe
from typing import Tuple
from config import appname, config
from config import appcmdname, appname, config
# TODO: Tests:
#
@ -327,6 +328,17 @@ class EDMCContextFilter(logging.Filter):
return module_name
def get_main_logger() -> logging.Logger:
"""Return the correct logger for how the program is being run."""
if not os.getenv("EDMC_NO_UI"):
# GUI app being run
return logging.getLogger(appname)
else:
# Must be the CLI
return logging.getLogger(appcmdname)
# Singleton
loglevel = config.get('loglevel')
if not loglevel: