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

With call depth additive #28

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21

- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -24,8 +24,8 @@ jobs:
strategy:
matrix:
go-version:
- 1.18.x
- 1.19.x
- 1.20.x
- 1.21.x
platform:
- ubuntu-latest
- macos-latest
Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -49,9 +49,9 @@ jobs:
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.21.x

- name: Checkout code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion logrusr.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (l *logrusr) copyLogger() *logrusr {
// when reporting caller.
func (l *logrusr) WithCallDepth(depth int) logr.LogSink {
newLogger := l.copyLogger()
newLogger.depth = depth
newLogger.depth += depth

return newLogger
}
Expand Down
15 changes: 15 additions & 0 deletions logrusr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,21 @@ func TestLogging(t *testing.T) {
"caller": `~testing.go:\d+`,
},
},
{
description: "with call depth is additive",
logFunc: func(log logr.Logger) {
log.
WithCallDepth(1).
WithCallDepth(1).
Info("hello, world")
},
reportCaller: true,
assertions: map[string]string{
"level": "info",
"msg": "hello, world",
"caller": `~testing.go:\d+`,
},
},
}

for _, tc := range cases {
Expand Down