diff --git a/src/sidecar.py b/src/sidecar.py index a48b0a16..6312b958 100644 --- a/src/sidecar.py +++ b/src/sidecar.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -import os -import re +import os, sys, re from kubernetes import client, config from kubernetes.client import ApiException @@ -33,6 +32,17 @@ logger = get_logger() +def exception_handler(exc_type, exc_value, exc_traceback): + if issubclass(exc_type, KeyboardInterrupt): + sys.__excepthook__(exc_type, exc_value, exc_traceback) + return + + logger.error("%s: %s" % (exc_type.__qualname__, exc_value), exc_info=(exc_type, exc_value, exc_traceback)) + + +sys.excepthook = exception_handler + + def main(): logger.info("Starting collector")