Hi! I often use this library. It is very useful and I love it.
When the logger using JsonFormatter logs exceptions, the output is like this.
{
"asctime": "2024-12-16 16:29:19,170",
"levelname": "ERROR",
"name": "my-logger",
"message": "Unexpected Error",
"exc_info": "Traceback (most recent call last):\n File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 20, in <module>\n do_something()\n File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 14, in do_something\n raise Exception(\"something wrong\")\nException: something wrong"
}
The stack trace is hard to read. It should be more readable like this.
{
"asctime": "2024-12-16 16:48:29,666",
"levelname": "ERROR",
"name": "my-logger",
"message": "Unexpected Error",
"exc_info": [
"Traceback (most recent call last):",
" File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 20, in <module>",
" do_something()",
" File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 14, in do_something",
" raise Exception(\"something wrong\")",
"Exception: something wrong"
]
}
Proposal
- Add Option such like
stack_trace_as_array to JsonFormatter.
- default:
False for backward compatibility.
- if
True, The formatter encodes stack traces as an array.
If you agree this feature, I will create PR.
Hi! I often use this library. It is very useful and I love it.
When the logger using
JsonFormatterlogs exceptions, the output is like this.{ "asctime": "2024-12-16 16:29:19,170", "levelname": "ERROR", "name": "my-logger", "message": "Unexpected Error", "exc_info": "Traceback (most recent call last):\n File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 20, in <module>\n do_something()\n File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 14, in do_something\n raise Exception(\"something wrong\")\nException: something wrong" }The stack trace is hard to read. It should be more readable like this.
{ "asctime": "2024-12-16 16:48:29,666", "levelname": "ERROR", "name": "my-logger", "message": "Unexpected Error", "exc_info": [ "Traceback (most recent call last):", " File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 20, in <module>", " do_something()", " File \"/Users/hakusai/src/hakusai/stacktrace-as-array/main.py\", line 14, in do_something", " raise Exception(\"something wrong\")", "Exception: something wrong" ] }Proposal
stack_trace_as_arraytoJsonFormatter.Falsefor backward compatibility.True, The formatter encodes stack traces as an array.If you agree this feature, I will create PR.