-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(log): add stacktrace display option (#16825)
- Loading branch information
1 parent
8344a78
commit 88f2c83
Showing
6 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package log_test | ||
|
||
import ( | ||
"bytes" | ||
"errors" | ||
"strings" | ||
"testing" | ||
|
||
"cosmossdk.io/log" | ||
) | ||
|
||
func TestLoggerOptionStackTrace(t *testing.T) { | ||
t.Skip() // todo(@julienrbrt) unskip when https://github.com/rs/zerolog/pull/560 merged | ||
|
||
buf := new(bytes.Buffer) | ||
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()) | ||
} | ||
buf.Reset() | ||
|
||
logger = log.NewLogger(buf, log.TraceOption(false), log.ColorOption(false)) | ||
logger.Error("this log should be displayed", "error", inner()) | ||
if strings.Count(buf.String(), "logger_test.go") > 0 { | ||
t.Fatalf("stack trace found, got: %s", buf.String()) | ||
} | ||
} | ||
|
||
func inner() error { | ||
return errors.New("seems we have an error here") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters