app and default logging joined except of fmt

This commit is contained in:
Dirk Alders 2025-08-04 08:34:08 +02:00
parent c9642f1a2b
commit 5995368f07

View File

@ -43,7 +43,7 @@ except ImportError:
try:
from config import LOG_LEVEL
except ImportError:
LOG_LEVEL = logging.DEBUG
LOG_LEVEL = logging.WARNING
try:
from config import LOG_HOSTNAME
except ImportError:
@ -215,22 +215,6 @@ def add_handler_socket(logger: logging.Logger, level: int = logging.DEBUG, host:
return handler
def app_logging_config():
"""You are able to configure logging by a config file including these line:
DEBUG = False
#
# Logging
#
APP_NAME = "<YOUR_APP_NAME>"
LOG_HOSTNAME = "loggy" # When DEBUG is True
"""
logger = logging.getLogger(ROOT_LOGGER_NAME)
if DEBUG:
add_handler_socket(logger, host=LOG_HOSTNAME)
return logger.getChild('main')
def default_logging_config(fmt=JOURNAL_FMT):
"""You are able to configure logging by a config file including these line:
@ -248,7 +232,16 @@ def default_logging_config(fmt=JOURNAL_FMT):
logger = logging.getLogger(ROOT_LOGGER_NAME)
add_handler_stdout(logger, LOG_LEVEL, fmt=fmt)
return app_logging_config()
if DEBUG:
add_handler_socket(logger, host=LOG_HOSTNAME)
return logger.getChild('main')
def app_logging_config():
"""
For details see comment in default_logging_config.
"""
return default_logging_config(LONG_FMT)
class testSession(dict):