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

fix: logr pkg too many params #67

Merged
merged 1 commit into from
Apr 25, 2024
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
2 changes: 1 addition & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type Logger interface {
// scope. To disable all output, you can use LogLevelNone.
//
// IncreaseLevel is only allowed to increase the level the Logger was initialized at -
// it has no affect if the preset level is higher than the inidcated level.
// it has no affect if the preset level is higher than the indicated level.
IncreaseLevel(scope string, description string, level Level) Logger
}

Expand Down
3 changes: 2 additions & 1 deletion logr/fields.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package logr

import (
"github.com/sourcegraph/log"
"go.uber.org/zap"

"github.com/sourcegraph/log"
)

func toLogFields(keysAndValues []any) []log.Field {
Expand Down
3 changes: 2 additions & 1 deletion logr/fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package logr
import (
"testing"

"github.com/sourcegraph/log"
"github.com/stretchr/testify/assert"

"github.com/sourcegraph/log"
)

func TestToLogFields(t *testing.T) {
Expand Down
29 changes: 15 additions & 14 deletions logr/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@ replace github.com/sourcegraph/log => ../
require (
github.com/go-logr/logr v1.2.3
github.com/sourcegraph/log v0.0.0-20230118185536-8e43a48b83a9
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.8.2
go.uber.org/zap v1.24.0
)

require (
github.com/cockroachdb/errors v1.9.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/getsentry/sentry-go v0.13.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/getsentry/sentry-go v0.21.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
111 changes: 37 additions & 74 deletions logr/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion logr/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func GetLogger(l logr.Logger) (log.Logger, bool) {
sink, ok := l.GetSink().(*LogSink)
if !ok {
return log.Scoped("logr", "new log.Logger created from logr.Logger"), false
return log.Scoped("logr"), false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual fix here

}
return sink.Logger, true
}
3 changes: 2 additions & 1 deletion logr/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package logr
import (
"testing"

"github.com/sourcegraph/log/logtest"
"github.com/stretchr/testify/assert"

"github.com/sourcegraph/log/logtest"
)

func TestGetLogger(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion logr/logr.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ func (s LogSink) WithValues(keysAndValues ...any) logr.LogSink {
// WithName returns a new LogSink with the specified name appended. See
// Logger.WithName for more details.
func (s LogSink) WithName(name string) logr.LogSink {
return &LogSink{s.Logger.Scoped(name, "")}
return &LogSink{s.Logger.Scoped(name)}
}
Loading