Skip to content

Commit

Permalink
Fix frame skip for standard library (#373)
Browse files Browse the repository at this point in the history
The previous caller skip was too aggressive; reduce the skip to properly capture the caller.
  • Loading branch information
flisky authored and akshayjshah committed Mar 14, 2017
1 parent 79e323d commit 78c612c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion global.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
_stdLogDefaultDepth = 4
_stdLogDefaultDepth = 2
_loggerWriterDepth = 1
)

Expand Down
7 changes: 6 additions & 1 deletion global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ func TestNewStdLog(t *testing.T) {
entry := logs.AllUntimed()[0]
assert.Equal(t, []zapcore.Field{}, entry.Context, "Unexpected entry context.")
assert.Equal(t, "redirected", entry.Entry.Message, "Unexpected entry message.")
assert.Contains(t, entry.Entry.Caller.File, "global_test.go", "Unexpected caller annotation.")
assert.Regexp(
t,
`go.uber.org/zap/global_test.go:\d+$`,
entry.Entry.Caller.String(),
"Unexpected caller annotation.",
)
})
}

Expand Down

0 comments on commit 78c612c

Please sign in to comment.