From bf129b201d741e53fb9b1a8f5e79fffb66f96ba0 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Thu, 1 Aug 2024 19:34:48 +0200 Subject: [PATCH] more straightforward logging --- backend/src/constants.py | 22 +++++++++++++--------- backend/src/log_config.yaml | 35 ----------------------------------- 2 files changed, 13 insertions(+), 44 deletions(-) delete mode 100644 backend/src/log_config.yaml diff --git a/backend/src/constants.py b/backend/src/constants.py index e9a4be2..64dceb7 100644 --- a/backend/src/constants.py +++ b/backend/src/constants.py @@ -15,16 +15,20 @@ OSM_CACHE_DIR = Path(cache_dir_string) import logging -import yaml - -LOGGING_CONFIG = LOCATION_PREFIX / 'log_config.yaml' -config = yaml.safe_load(LOGGING_CONFIG.read_text()) - -logging.config.dictConfig(config) - -# if we are in a debug session, set the log level to debug +# if we are in a debug session, set verbose and rich logging if os.getenv('DEBUG', False): - logging.getLogger().setLevel(logging.DEBUG) + from rich.logging import RichHandler + logging.basicConfig( + level=logging.DEBUG, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + handlers=[RichHandler()] + ) +else: + logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + ) + MEMCACHED_HOST_PATH = os.getenv('MEMCACHED_HOST_PATH', None) if MEMCACHED_HOST_PATH == "none": diff --git a/backend/src/log_config.yaml b/backend/src/log_config.yaml deleted file mode 100644 index 4cb27f9..0000000 --- a/backend/src/log_config.yaml +++ /dev/null @@ -1,35 +0,0 @@ -version: 1 -disable_existing_loggers: False -formatters: - simple: - format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' -handlers: - console: - class: rich.logging.RichHandler - formatter: simple - width: 255 - # access: - # class: logging.FileHandler - # filename: logs/access.log - # level: INFO - # formatter: simple - - - - -loggers: - uvicorn.error: - level: INFO - handlers: - - console - propagate: no - # uvicorn.access: - # level: INFO - # handlers: - # - access - # propagate: no -root: - level: INFO - handlers: - - console - propagate: yes