more straightforward logging

This commit is contained in:
2024-08-01 19:34:48 +02:00
parent 86bcec6b29
commit bf129b201d
2 changed files with 13 additions and 44 deletions

View File

@@ -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":