Switch to LokiQueueHandler

This commit is contained in:
PapaTutuWawa 2023-12-23 21:42:59 +01:00
parent c9ba680bbf
commit 2718e72a80

View File

@ -8,9 +8,8 @@ def init_loki_logging(config: dict[str, str]):
"""Configures the logging to Loki."""
import logging_loki
queue = Queue(-1)
handler = logging.handlers.QueueHandler(queue)
handler_loki = logging_loki.LokiHandler(
handler = logging_loki.LokiQueueHandler(
Queue(-1),
url=config["loki"]["url"],
version="1",
tags={
@ -22,7 +21,6 @@ def init_loki_logging(config: dict[str, str]):
datefmt="%Y-%m-%d-%H:%M:%S",
)
handler.setFormatter(formatter)
logging.handlers.QueueListener(queue, handler_loki)
logging.getLogger().addHandler(handler)