We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1506957 commit 1714eeeCopy full SHA for 1714eee
small_bug_lab/trackback_per_line.py
@@ -0,0 +1,35 @@
1
+# coding: utf-8
2
+# @Time : 2021/3/27 8:43 AM
3
+
4
5
+from tool.log_ext import LogExt
6
7
+log = LogExt().get_logger
8
9
10
+def division(a, b):
11
+ return a / b
12
13
+#
14
+# # 仅捕获原因
15
+# try:
16
+# d = division(1, 0)
17
+# except Exception as e:
18
+# log.error(f"error happened reason: {e}")
19
20
21
+# 打印堆栈信息
22
23
24
25
+# log.exception(e)
26
27
28
+# 以每一行的形式打印出来
29
+import sys, traceback
30
+try:
31
+ d = division(1, 0)
32
+except Exception as e:
33
+ for e_info in traceback.format_exception(*sys.exc_info()):
34
+ for _ in e_info[:-1].split("\n"):
35
+ log.tback(_)
0 commit comments