Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
smilefisher authored Sep 11, 2024
2 parents b88b6a7 + 908e625 commit 525bbc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions contrib/log/zap/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"github.com/go-kratos/kratos/v2/log"
)
Expand Down Expand Up @@ -32,6 +33,11 @@ func NewLogger(zlog *zap.Logger) *Logger {
}

func (l *Logger) Log(level log.Level, keyvals ...interface{}) error {
// If logging at this level is completely disabled, skip the overhead of
// string formatting.
if zapcore.Level(level) < zapcore.DPanicLevel && !l.log.Core().Enabled(zapcore.Level(level)) {
return nil
}
var (
msg = ""
keylen = len(keyvals)
Expand Down
13 changes: 9 additions & 4 deletions transport/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ func (x *mockCallOption) after(_ *callInfo, _ *csAttempt) {
log.Println("run in mockCallOption.after")
}

func TestWithSubset(t *testing.T) {
co := &clientOptions{}
o := WithSubset(1)
o(co)
if co.subsetSize != 1 {
t.Error("expected subset size to be 1")
}
}

func TestWithTransport(t *testing.T) {
ov := &mockRoundTripper{}
o := WithTransport(ov)
Expand Down Expand Up @@ -71,10 +80,6 @@ func TestWithBlock(t *testing.T) {
}
}

func TestWithBalancer(_ *testing.T) {
// TODO
}

func TestWithTLSConfig(t *testing.T) {
ov := &tls.Config{}
o := WithTLSConfig(ov)
Expand Down
4 changes: 0 additions & 4 deletions transport/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,6 @@ func TestTimeout(t *testing.T) {
}
}

func TestLogger(_ *testing.T) {
// TODO
}

func TestRequestDecoder(t *testing.T) {
o := &Server{}
v := func(*http.Request, interface{}) error { return nil }
Expand Down

0 comments on commit 525bbc9

Please sign in to comment.