Skip to content

Feature request: Parse exceptions into structured logs #1268

Closed
@Nogginboink

Description

@Nogginboink

Use case

When using the logger and logging an exception, the exception traceback appears as a single string that includes the stack trace, each frame of which has a file, a line number, a function name, and the statement on that line. Parsing that line, either with the Mk I eyeball or with code, is difficult

Solution/User Experience

Because logger is all about structured logging, it would be nice if the stack backtrace were structured as well. Something like:

Traceback = [
  {
    "File" : "myfile.py",
    "Line" : 44,
    "Function" : "do_something_risky",
    "Statement": "do_division(x, 0)"
  },
  {
    "File" : "myotherfile.py",
    "Line": 12,
    "Function" : "do_division",
    "Statement" : "return numerator/denominator
  }
]

Alternative solutions

There are no good ones that I'm aware of. I might be able to overload the existing functions in the traceback module, but doing that for every lambda function in my solution is not ideal

Acknowledgment

Metadata

Metadata

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions