Skip to content

Commit e398c57

Browse files
authored
feat: format stack_info if given
1 parent 27347d9 commit e398c57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/logfmter/formatter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ def format(self, record: logging.LogRecord) -> str:
245245
if record.exc_info:
246246
# Cast exc_info to its not null variant to make mypy happy.
247247
exc_info = cast(ExcInfo, record.exc_info)
248+
tokens.append(f"exc_info={self.format_exc_info(exc_info)}")
248249

249-
tokens.append("exc_info={}".format(self.format_exc_info(exc_info)))
250+
if record.stack_info:
251+
stack_info = self.formatStack(record.stack_info).rstrip("\n")
252+
tokens.append(f"stack_info={self.format_string(stack_info)}")
250253

251254
return " ".join(tokens)

0 commit comments

Comments
 (0)