1. better_exceptions 包
Pretty and useful exceptions in Python, automatically.
github
eg:
import sys
import logging
import better_exceptions
logger = logging.getLogger(__name__)
try:
a = {
1: 1, 2: 2, 3: 34, 4: [1, 2, 3, 45]}
print(a[6])
except Exception as e:
lines = better_exceptions.format_exception(e.__class__, e, sys.exc_info()[2])
logger.error("".join(lines))
better_exceptions resut:
Traceback (most recent call last):
File "/home/feng.liu/project/PycharmProjects/ccluoshu_prod/enigma/test/te_set.py", line 26, in <module>
print(a[6])
└ {
<