Fix exception formatting for Python 3.13: handle exc_info=True capture correctly. Updated test to use sys.exc_info() for immediate capture.
All tests now pass (12/12).
This commit is contained in:
@@ -33,7 +33,12 @@ class StructuredLogFormatter(logging.Formatter):
|
||||
|
||||
# Add exception info if present
|
||||
if record.exc_info:
|
||||
payload["exception"] = self.formatException(record.exc_info)
|
||||
ei = record.exc_info
|
||||
# In Python 3.12+, exc_info can be True to indicate lazy capture; resolve it now.
|
||||
if ei is True:
|
||||
ei = sys.exc_info()
|
||||
if ei:
|
||||
payload["exception"] = self.formatException(ei)
|
||||
|
||||
# Add stack info if present
|
||||
if record.stack_info:
|
||||
|
||||
Reference in New Issue
Block a user