aws-auto-remediate
aws-auto-remediate copied to clipboard
Use exc_info kwarg for logging.log()
https://docs.python.org/3/library/logging.html#logging.Logger.debug
Instead of, for example,
https://github.com/servian/aws-auto-remediate/blob/b4ea0b0938d358b607716285b0ba641127d954ed/auto_remediate/lambda_handler.py#L163-L167
The following achieves the same:
self.logging.error(
f"Could not read DynamoDB table '{os.environ['SETTINGSTABLE']}'.",
exc_info=True
)
@jihygk I tried implementing this but unfortunately it prints and entire stack trace (which dirties up the logs) which is what I got around by only taking the second tupple sys.exc_info()[1]
. You can override the behaviour by implementing formatException(exc_info) but it's more complex.