@@ -253,17 +253,11 @@ def format(self, record: logging.LogRecord) -> str:
253
253
if not message_dict .get ("exc_info" ) and record .exc_text :
254
254
message_dict ["exc_info" ] = record .exc_text
255
255
256
- if self .exc_info_as_array and message_dict .get ("exc_info" ):
257
- message_dict ["exc_info" ] = message_dict ["exc_info" ].splitlines ()
258
-
259
256
# Display formatted record of stack frames
260
257
# default format is a string returned from :func:`traceback.print_stack`
261
258
if record .stack_info and not message_dict .get ("stack_info" ):
262
259
message_dict ["stack_info" ] = self .formatStack (record .stack_info )
263
260
264
- if self .stack_info_as_array and message_dict .get ("stack_info" ):
265
- message_dict ["stack_info" ] = message_dict ["stack_info" ].splitlines ()
266
-
267
261
log_record : LogRecord = {}
268
262
self .add_fields (log_record , record , message_dict )
269
263
log_record = self .process_log_record (log_record )
@@ -380,3 +374,23 @@ def process_log_record(self, log_record: LogRecord) -> LogRecord:
380
374
log_record: incoming data
381
375
"""
382
376
return log_record
377
+
378
+ def formatException (self , ei ) -> Union [str , list [str ]]:
379
+ """Format and return the specified exception information.
380
+
381
+ If exc_info_as_array is set to True, This method returns an array of strings.
382
+ """
383
+ exception_info_str = super ().formatException (ei )
384
+ return exception_info_str .splitlines () if self .exc_info_as_array else exception_info_str
385
+
386
+ def formatStack (self , stack_info ) -> Union [str , list [str ]]:
387
+ """Format and return the specified stack information.
388
+
389
+ If stack_info_as_array is set to True, This method returns an array of strings.
390
+ """
391
+ stack_info_str = super ().formatStack (stack_info )
392
+ return (
393
+ stack_info_str .splitlines ()
394
+ if self .stack_info_as_array
395
+ else stack_info_str .formatStack (stack_info )
396
+ )
0 commit comments