My setup code:
loki_handler = LokiLoggerHandler(
url=LOKI_ADDR + "/loki/api/v1/push",
labels={"service_name": PROJECT_NAME},
label_keys={"level": "level"},
timeout=10,
enable_self_errors=True,
)
loki_handler.setFormatter(logging.Formatter(plain_fmt))
According to the README, logging.Formatter is supposed to be supportted, but it actually isn't. Here's the error I encountered:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/loki_logger_handler/loki_logger_handler.py", line 103, in emit
formatted_record, log_loki_metadata = self.formatter.format(record)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/loki_logger_handler/loki_logger_handler.py", line 103, in emit
formatted_record, log_loki_metadata = self.formatter.format(record)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)
During handling of the above exception, another exception occurred:
(...and many duplicated logs...)
Seems that the recursive errors are due to enable_self_errors=True
In the source code of logging, logging.Formatter only returns 1 value:

My setup code:
According to the README,
logging.Formatteris supposed to be supportted, but it actually isn't. Here's the error I encountered:In the source code of
logging,logging.Formatteronly returns 1 value: