Proper way to handle logging of exceptions

This commit is contained in:
giuliof 2021-09-04 11:13:41 +02:00
parent 34dbffac9f
commit df82337f1f
1 changed files with 3 additions and 2 deletions

View File

@ -122,5 +122,6 @@ try:
# Wanna get a pretty JSON encoded library to do your nasty things offline at home? ;-)
print(json.dumps(result, indent=4))
except:
logging.error("Unexpected error:", sys.exc_info()[0])
# Avoid printing on str{out,err} the unexpected exception traces. Log it instead.
except Exception as e:
logging.exception(e)