Skip to content

Commit

Permalink
import mess fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuhtz committed Jul 16, 2024
1 parent 3f12024 commit 7306b8b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions api/tooling/__init__.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions api/tooling/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from api.tooling.logger_init import logger_init

logger = logger_init() # specify 'DEBUG' if early debugging (env) is needed
8 changes: 3 additions & 5 deletions api/tooling/logger_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import logging
import sys

from api.tooling import set_log_level
from tracemalloc import start

class CustomFormatter(logging.Formatter):
"""
Expand Down Expand Up @@ -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.
Expand All @@ -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
2 changes: 1 addition & 1 deletion api/tooling/set_log_level.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 7306b8b

Please sign in to comment.