File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,14 @@ def update_format(self, record):
64
64
"%(asctime)s │ "
65
65
f"{ prefix } { color } %(levelname)-8s{ prefix } { reset } │ "
66
66
)
67
- self ._style ._fmt += (
68
- f"%(indent)s{ prefix } { bold } %(function)s{ prefix } { reset } : "
69
- "%(message)s"
70
- )
67
+ if hasattr (record , "function" ):
68
+ self ._style ._fmt += (
69
+ f"%(indent)s{ prefix } { bold } %(function)s{ prefix } { reset } : "
70
+ "%(message)s"
71
+ )
72
+ else :
73
+ self ._style ._fmt += f"%(indent)s%(message)s"
74
+
71
75
72
76
def format (self , record ):
73
77
"""
@@ -81,19 +85,21 @@ def format(self, record):
81
85
self .baseline = depth
82
86
if self .cut is None :
83
87
filenames = map (lambda x : x .filename , stack )
84
- self .cut = IndentFormatter .identify_cut (filenames )
88
+ self .cut = self .identify_cut (filenames )
85
89
86
90
# Inject custom information into the record
87
91
record .indent = ". " * (depth - self .baseline + self .manual_push )
88
- record .function = stack [self .cut ].function
92
+ if depth > self .cut :
93
+ record .function = stack [self .cut ].function
89
94
90
95
# Format the record using custom information
91
96
self .update_format (record )
92
97
out = super ().format (record )
93
98
94
99
# Remove custom information from the record
95
100
del record .indent
96
- del record .function
101
+ if hasattr (record , "function" ):
102
+ del record .function
97
103
98
104
return out
99
105
You can’t perform that action at this time.
0 commit comments