Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Use exc_info kwarg for logging.log() #36

Open
jihygk opened this issue May 24, 2019 · 1 comment
Open

Use exc_info kwarg for logging.log() #36

jihygk opened this issue May 24, 2019 · 1 comment
Labels
tech debt Technical debt

Comments

@jihygk
Copy link
Contributor

jihygk commented May 24, 2019

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 jihygk added the tech debt Technical debt label May 24, 2019
mlevit added a commit that referenced this issue May 24, 2019
@mlevit mlevit self-assigned this May 24, 2019
@mlevit
Copy link
Owner

mlevit commented May 26, 2019

@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.

@mlevit mlevit removed their assignment May 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tech debt Technical debt
Projects
None yet
Development

No branches or pull requests

2 participants