Skip to content
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(zapslog): implement stack trace handling #1339

Merged
merged 18 commits into from
Sep 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: Don't use require.New
We avoid use of assert.New and require.New in our tests.
  • Loading branch information
abhinav committed Aug 27, 2023
commit 41948fb84d1644a7aef59af534b21ccab4284f0a
5 changes: 2 additions & 3 deletions exp/zapslog/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ func TestAddCaller(t *testing.T) {
}

func TestAddStack(t *testing.T) {
r := require.New(t)
fac, logs := observer.New(zapcore.DebugLevel)
sl := slog.New(NewHandler(fac, AddStacktraceAt(slog.LevelDebug)))
sl.Info("msg")

r.Len(logs.AllUntimed(), 1, "Expected exactly one entry to be logged")
require.Len(t, logs.AllUntimed(), 1, "Expected exactly one entry to be logged")
entry := logs.AllUntimed()[0]
r.Equal("msg", entry.Message, "Unexpected message")
require.Equal(t, "msg", entry.Message, "Unexpected message")
assert.Regexp(t,
`^go.uber.org/zap/exp/zapslog.TestAddStack`,
entry.Stack,
Expand Down