-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structured stacktrace? #9
Comments
I would say that internally, we definitely need a structured stacktrace, but the way we output the logs should be customizable. Option 1: What about a custom slog.Valuer, json.Marshaler, etc... ? I think we can add some interfaces such as: type LogValuerFormatter interface {
Format(OopsError) slog.Valuer
}
type JsonFormatter interface {
Format(OopsError) ([]byte, error)
}
type MapFormatter interface {
Format(OopsError) map[string]any
}
type StdFormatter interface {
Format(err OopsError, s fmt.State, verb rune)
}
const (
DefaultLogValuerFormatter LogValuerFormatter = ...
DefaultJsonFormatter JsonFormatter = ...
DefaultMapFormatter MapFormatter = ...
DefaultStdFormatter StdFormatter = ...
) Option 2: It might be the job of the logger to handle the error and format it. Returning a slice would allow the logger to print it as a string. Option 3: A mix of both options 1 and 2. This is probably the best option since WDYT ? |
I'm sorry but I just hoped oops stacktrace is more readable for slog.TextHandler/slog.JsonHandler (the only logger I care since slog is in std) by default. If it's structured, It would also be possible get statistical results on the error with log. Instead of
something like
|
The format would be: [
{
"message":"error internal server",
"stacktrace":[
"github.com/samber/oops/examples/slog/example.go:30:d()",
"github.com/samber/oops/examples/slog/example.go:34:c()",
"github.com/samber/oops/examples/slog/example.go:42:b()",
"github.com/samber/oops/examples/slog/example.go:46:a()"
]
}
] You can start with the update on the stacktrace package then |
Has there been any progress on cleaning up the stacktrace for structured formatting? |
Current stacktrace just append strings, which is not good to read.
Can oops have some structured stacktrace implementation like https://github.com/rotisserie/eris ?
The text was updated successfully, but these errors were encountered: