Logging handler to send logs to your OpenSearch cluster with bulk SSL. Forked from https://github.com/logzio/logzio-python-handler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
538 B

import functools
import logging
class LogzioFlusher(logging.Logger):
def __init__(self, logger):
self.logger = logger
def __call__(self, function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
try:
return function(*args, **kwargs)
except Exception as e:
self.logger.exception('call failed: {}'.format(e))
raise
finally:
[h.flush() for h in self.logger.root.handlers]
return wrapper