logging.Handler already has self.formatter and a setter method for it, but the setter method does nothing because the lokiLoggingHander does use its own formatter variable.
This just lead to a lot of confusion
class LokiLoggerHandler(logging.Handler):
def __init__(
self,
url,
labels,
labelKeys=None,
timeout=10,
compressed=True,
defaultFormatter=LoggerFormatter(),
additional_headers=dict()
):
super().__init__()
if labelKeys is None:
labelKeys = {}
self.labels = labels
self.labelKeys = labelKeys
self.timeout = timeout
self.logger_formatter = defaultFormatter # This should be just self.formatter
self.request = LokiRequest(url=url, compressed=compressed, additional_headers=additional_headers)
self.buffer = queue.Queue()
self.flush_thread = threading.Thread(target=self._flush, daemon=True)
self.flush_thread.start()
just changing that one variable decleration makes it easier for the logger to be a drop in replacement for another handler
logging.Handler already has self.formatter and a setter method for it, but the setter method does nothing because the lokiLoggingHander does use its own formatter variable.
This just lead to a lot of confusion
just changing that one variable decleration makes it easier for the logger to be a drop in replacement for another handler