-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat(log): add stacktrace display option #16825
Conversation
@@ -3,6 +3,7 @@ module cosmossdk.io/log | |||
go 1.20 | |||
|
|||
require ( | |||
github.com/pkg/errors v0.9.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a archived dependency. Any chance we can use std lib or hashicorp errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was based on https://github.com/rs/zerolog#error-logging-with-stacktrace.
I'll see if creating a custom ErrorStackMarshaler
make sense 👀
Lgtm. We can worry about the dev later as it won't cause issues |
logger := log.NewLogger(buf, log.TraceOption(true), log.ColorOption(false)) | ||
logger.Error("this log should be displayed", "error", inner()) | ||
if strings.Count(buf.String(), "logger_test.go") != 1 { | ||
t.Fatalf("stack trace not found, got: %s", buf.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently failing, It seems like ErrorStackMarshaler
is only called in Err()
but not when using Fields
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not tag after this PR but use a pseudo version in the SDK until #16825 (comment) is merged. If it gets merge then we can tag a 1.2.0. |
Description
In the SDK implementation of
cosmossdk.io/log
there is a confusion between thetrace
level (like error,info,debug,...) and displaying the stack trace of an error. The logger currently does not support the latter, while the--trace
flag is for that. This PR adds the functionality to the logger lib.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change