use additional loki logger
Some checks failed
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 1m27s
Build and deploy the backend to staging / Build and push image (pull_request) Failing after 20s
Build and deploy the backend to staging / Deploy to staging (pull_request) Has been skipped
Some checks failed
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 1m27s
Build and deploy the backend to staging / Build and push image (pull_request) Failing after 20s
Build and deploy the backend to staging / Deploy to staging (pull_request) Has been skipped
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Module allowing to access the parameters of route generation"""
|
||||
"""Module setting global parameters for the application, such as logging, cache, route generation, etc."""
|
||||
|
||||
import logging
|
||||
import os
|
||||
@@ -16,19 +16,33 @@ cache_dir_string = os.getenv('OSM_CACHE_DIR', './cache')
|
||||
OSM_CACHE_DIR = Path(cache_dir_string)
|
||||
|
||||
|
||||
# if we are in a debug session, set verbose and rich logging
|
||||
if os.getenv('DEBUG', "false") == "true":
|
||||
# if we are in a debug (local) session, set verbose and rich logging
|
||||
debug = os.getenv('DEBUG', "false") == "true"
|
||||
if os.getenv('KUBERNETES_SERVICE_HOST', None) is not None:
|
||||
# in that case we want to log to stdout and also to loki
|
||||
from loki_logger_handler.loki_logger_handler import LokiLoggerHandler
|
||||
loki_handler = LokiLoggerHandler(
|
||||
url=os.getenv('LOKI_URL', 'http://loki:3100'),
|
||||
labels={'app': 'anyway', 'env': 'production' if debug else 'staging'}
|
||||
)
|
||||
if debug:
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
handlers=[loki_handler, logging.StreamHandler()]
|
||||
)
|
||||
else:
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
handlers=[loki_handler, logging.StreamHandler()]
|
||||
)
|
||||
else:
|
||||
# in that case we are local and we want to log to stdout only, but make it pretty
|
||||
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)
|
||||
|
@@ -11,7 +11,7 @@ from .utils.landmarks_manager import LandmarkManager
|
||||
from .utils.toilets_manager import ToiletsManager
|
||||
from .utils.optimizer import Optimizer
|
||||
from .utils.refiner import Refiner
|
||||
from .persistence import client as cache_client
|
||||
from .cache import client as cache_client
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@@ -4,7 +4,7 @@ from fastapi import HTTPException
|
||||
from pydantic import ValidationError
|
||||
|
||||
from ..structs.landmark import Landmark
|
||||
from ..persistence import client as cache_client
|
||||
from ..cache import client as cache_client
|
||||
|
||||
|
||||
def landmarks_to_osmid(landmarks: list[Landmark]) -> list[int] :
|
||||
|
Reference in New Issue
Block a user