From f49d3729f78cba3c7031dd46e6b368e53852d455 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Thu, 22 Apr 2021 22:36:02 -0700 Subject: [PATCH] simpler logr.New() signature --- examples/tab_logger.go | 2 +- funcr/funcr.go | 2 +- logr.go | 5 ++--- logr_test.go | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/tab_logger.go b/examples/tab_logger.go index 46e2ac2..46df2db 100644 --- a/examples/tab_logger.go +++ b/examples/tab_logger.go @@ -82,5 +82,5 @@ func NewTabLogger() logr.Logger { sink := tabLogSink{ writer: tabwriter.NewWriter(os.Stderr, 40, 8, 2, '\t', 0), } - return logr.New(0, sink) + return logr.New(sink) } diff --git a/funcr/funcr.go b/funcr/funcr.go index 923c80e..34c19f4 100644 --- a/funcr/funcr.go +++ b/funcr/funcr.go @@ -41,7 +41,7 @@ func New(fn func(prefix, args string), opts Options) logr.Logger { logCaller: opts.LogCaller, verbosity: opts.Verbosity, } - return logr.New(0, fnl) + return logr.New(fnl) } type Options struct { diff --git a/logr.go b/logr.go index 8bb4381..05e36e5 100644 --- a/logr.go +++ b/logr.go @@ -171,10 +171,9 @@ import ( // New returns a new Logger instance. This is primarily used by libraries // implementing LogSink, rather than end users. -func New(level int, sink LogSink) Logger { +func New(sink LogSink) Logger { logger := Logger{ - level: level, - sink: sink, + sink: sink, } if withCallDepth, ok := sink.(CallDepthLogSink); ok { logger.withCallDepth = withCallDepth diff --git a/logr_test.go b/logr_test.go index 619e544..60a1c7b 100644 --- a/logr_test.go +++ b/logr_test.go @@ -57,7 +57,7 @@ func TestContext(t *testing.T) { } sink := &testLogSink{} - logger := New(0, sink) + logger := New(sink) lctx := NewContext(ctx, logger) if out, err := FromContext(lctx); err != nil { t.Errorf("unexpected error: %v", err) @@ -87,7 +87,7 @@ func TestWithCallDepth(t *testing.T) { // Test an impl that does not support it. t.Run("not supported", func(t *testing.T) { in := &testLogSink{} - l := New(0, in) + l := New(in) out := l.WithCallDepth(42) if p := out.sink.(*testLogSink); p != in { t.Errorf("expected output to be the same as input: got in=%p, out=%p", in, p) @@ -97,7 +97,7 @@ func TestWithCallDepth(t *testing.T) { // Test an impl that does support it. t.Run("supported", func(t *testing.T) { in := &testCallDepthLogSink{&testLogSink{}, 0} - l := New(0, in) + l := New(in) out := l.WithCallDepth(42) if out.sink.(*testCallDepthLogSink) == in { t.Errorf("expected output to be different than input: got in=out=%p", in)