For example:
# foo.py
foo = 1
bar = foo + 2
raise ValueError("FIXME")
python foo.py will generate something like
Traceback (most recent call last):
File "/opt/app/foo.py", line 3
raise ValueError("FIXME")
But what if I want to format this error message into json string {"exc_info": "Traceback...", "level": "ERROR", ...}. Can I do this using logging module? I don't what to use try/except and logging.exception.