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

  1. import functools
  2. import logging
  3. class LogzioFlusher(logging.Logger):
  4. def __init__(self, logger):
  5. self.logger = logger
  6. def __call__(self, function):
  7. @functools.wraps(function)
  8. def wrapper(*args, **kwargs):
  9. try:
  10. return function(*args, **kwargs)
  11. except Exception as e:
  12. self.logger.exception('call failed: {}'.format(e))
  13. raise
  14. finally:
  15. [h.flush() for h in self.logger.root.handlers]
  16. return wrapper