diff --git a/api/api.py b/api/api.py index d3c8ad7..43b631a 100644 --- a/api/api.py +++ b/api/api.py @@ -5,7 +5,7 @@ from fastapi import FastAPI import uvicorn -from .tooling.logger_init import logger +from api.tooling.logger_init import logger from routers.configuration.operations import init_router as init_configuration_router from routers.database.operations import init_router as init_database_router from routers.internal.operations import init_router as init_swissarmy_router diff --git a/api/tooling/__init__.py b/api/tooling/__init__.py index 0a373e5..143f486 100644 --- a/api/tooling/__init__.py +++ b/api/tooling/__init__.py @@ -1,5 +1 @@ # __init__.py - -from .check_env_vars import check_env_vars -from .set_log_level import set_log_level -from .logger_init import logger_init \ No newline at end of file diff --git a/api/tooling/logger.py b/api/tooling/logger.py new file mode 100644 index 0000000..fa6409b --- /dev/null +++ b/api/tooling/logger.py @@ -0,0 +1,3 @@ +from api.tooling.logger_init import logger_init + +logger = logger_init() # specify 'DEBUG' if early debugging (env) is needed diff --git a/api/tooling/logger_init.py b/api/tooling/logger_init.py index 6c17bed..a8f5b90 100644 --- a/api/tooling/logger_init.py +++ b/api/tooling/logger_init.py @@ -2,8 +2,7 @@ import logging import sys - -from api.tooling import set_log_level +from tracemalloc import start class CustomFormatter(logging.Formatter): """ @@ -39,7 +38,7 @@ class ANSIColors: logging.CRITICAL: ANSIColors.bold_red + '%(levelname)s:' + ANSIColors.reset + '\t %(message)s' } -def define_logger(startup_logging_level: str = 'INFO') -> logging.Logger: +def logger_init(startup_logging_level: str = 'INFO') -> logging.Logger: """ Initialize logging.Logger with custom logging format based on logging severity level. @@ -59,8 +58,7 @@ def define_logger(startup_logging_level: str = 'INFO') -> logging.Logger: # set_log_level(logger, 'debug') # normally not needed, enable for debugging of env variables only - set_log_level(logging.getLevelName(startup_logging_level)) + logger.setLevel(logging.getLevelName(startup_logging_level)) return logger -logger = define_logger() # specify 'DEBUG' if early debugging (env) is needed diff --git a/api/tooling/set_log_level.py b/api/tooling/set_log_level.py index 0ee0104..542d8ef 100644 --- a/api/tooling/set_log_level.py +++ b/api/tooling/set_log_level.py @@ -1,5 +1,5 @@ from logging import Logger, getLevelName -from api.tooling.logger_init import logger +from api.tooling.logger import logger def set_log_level(level_str: str) -> None: