Skip to content

Commit 2d1d3f0

Browse files
authoredMar 25, 2022
feat: use info level to print log (#24)
1 parent 774fe46 commit 2d1d3f0

File tree

22 files changed

+49
-49
lines changed

22 files changed

+49
-49
lines changed
 

‎basic/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type EchoImpl struct{}
3131

3232
// Echo implements the Echo interface.
3333
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
34-
klog.Debug("echo called")
34+
klog.Info("echo called")
3535
return &api.Response{Message: req.Message}, nil
3636
}
3737

‎codec/json/codec.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (jc *JsonCodec) Encode(ctx context.Context, message remote.Message, out rem
5656
return perrors.NewProtocolError(fmt.Errorf("json encode, marshal payload failed: %w", err))
5757
}
5858
if jc.printDebugInfo {
59-
klog.Debugf("encoded payload: %s\n", payload)
59+
klog.Infof("encoded payload: %s\n", payload)
6060
}
6161
data := &Meta{
6262
ServiceName: message.RPCInfo().Invocation().ServiceName(),
@@ -106,7 +106,7 @@ func (jc *JsonCodec) Decode(ctx context.Context, message remote.Message, in remo
106106
return err
107107
}
108108
if jc.printDebugInfo {
109-
klog.Debugf("encoded payload: %s\n", data.Payload)
109+
klog.Infof("encoded payload: %s\n", data.Payload)
110110
}
111111
if remote.MessageType(data.MsgType) == remote.Exception {
112112
var exception Exception

‎codec/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type EchoImpl struct{}
3333

3434
// Echo implements the Echo interface.
3535
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
36-
klog.Debug("echo called")
36+
klog.Info("echo called")
3737
return &api.Response{Message: req.Message}, nil
3838
}
3939

‎discovery/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type EchoImpl struct{}
3131

3232
// Echo implements the Echo interface.
3333
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
34-
klog.Debug("echo called")
34+
klog.Info("echo called")
3535
return &api.Response{Message: req.Message}, nil
3636
}
3737

‎generic/client/binary/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func main() {
5050
if err != nil {
5151
klog.Fatal(err)
5252
}
53-
klog.Debug(result.Success)
53+
klog.Info(result.Success)
5454
time.Sleep(time.Second)
5555
}
5656
}

‎generic/client/http/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func doBizMethod1(cli genericclient.Client) error {
5151
klog.Fatalf("generic call failed: %v", err)
5252
}
5353
realResp := resp.(*generic.HTTPResponse)
54-
klog.Debugf("method1 response, status code: %v, headers: %v, body: %v\n", realResp.StatusCode, realResp.Header, realResp.Body)
54+
klog.Infof("method1 response, status code: %v, headers: %v, body: %v\n", realResp.StatusCode, realResp.Header, realResp.Body)
5555
return nil
5656
}
5757

@@ -78,7 +78,7 @@ func doBizMethod2(cli genericclient.Client) error {
7878
klog.Fatalf("generic call failed: %v", err)
7979
}
8080
realResp := resp.(*generic.HTTPResponse)
81-
klog.Debugf("method2 response, status code: %v, headers: %v, body: %v\n", realResp.StatusCode, realResp.Header, realResp.Body)
81+
klog.Infof("method2 response, status code: %v, headers: %v, body: %v\n", realResp.StatusCode, realResp.Header, realResp.Body)
8282
return nil
8383
}
8484

@@ -105,7 +105,7 @@ func doBizMethod3(cli genericclient.Client) error {
105105
klog.Fatalf("generic call failed: %v", err)
106106
}
107107
realResp := resp.(*generic.HTTPResponse)
108-
klog.Debugf("method3 response, status code: %v, headers: %v, body: %v\n", realResp.StatusCode, realResp.Header, realResp.Body)
108+
klog.Infof("method3 response, status code: %v, headers: %v, body: %v\n", realResp.StatusCode, realResp.Header, realResp.Body)
109109
return nil
110110
}
111111

‎generic/client/map/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func main() {
4747
if err != nil {
4848
log.Fatal(err)
4949
}
50-
klog.Debugf("response: %#v", resp)
50+
klog.Infof("response: %#v", resp)
5151
time.Sleep(time.Second)
5252
}
5353
}

‎generic/server/binary/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type EchoImpl struct{}
3131

3232
// Echo implements the Echo interface.
3333
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
34-
klog.Debug("echo called")
34+
klog.Info("echo called")
3535
return &api.Response{Message: req.Message}, nil
3636
}
3737

‎generic/server/http/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ type BizServiceImpl struct{}
2929

3030
// BizMethod1 implements the BizServiceImpl interface.
3131
func (s *BizServiceImpl) BizMethod1(ctx context.Context, req *http.BizRequest) (resp *http.BizResponse, err error) {
32-
klog.Debugf("BizMethod1 called, request: %#v", req)
32+
klog.Infof("BizMethod1 called, request: %#v", req)
3333
return &http.BizResponse{HttpCode: 200, Text: "Method1 response", Token: 1111}, nil
3434
}
3535

3636
// BizMethod2 implements the BizServiceImpl interface.
3737
func (s *BizServiceImpl) BizMethod2(ctx context.Context, req *http.BizRequest) (resp *http.BizResponse, err error) {
38-
klog.Debugf("BizMethod2 called, request: %#v", req)
38+
klog.Infof("BizMethod2 called, request: %#v", req)
3939
return &http.BizResponse{HttpCode: 200, Text: "Method2 response", Token: 2222}, nil
4040
}
4141

4242
// BizMethod3 implements the BizServiceImpl interface.
4343
func (s *BizServiceImpl) BizMethod3(ctx context.Context, req *http.BizRequest) (resp *http.BizResponse, err error) {
44-
klog.Debugf("BizMethod3 called, request: %#v", req)
44+
klog.Infof("BizMethod3 called, request: %#v", req)
4545
return &http.BizResponse{HttpCode: 200, Text: "Method3 response", Token: 3333}, nil
4646
}
4747

‎generic/server/map/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type GenericServiceImpl struct{}
3131
// GenericCall implements the Echo interface.
3232
func (s *GenericServiceImpl) GenericCall(ctx context.Context, method string, request interface{}) (response interface{}, err error) {
3333
m := request.(map[string]interface{})
34-
klog.Debugf("Recv: %v\n", m)
34+
klog.Infof("Recv: %v\n", m)
3535
return map[string]interface{}{
3636
"message": m["message"],
3737
}, nil

‎governance/server/limit/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type EchoImpl struct{}
3333

3434
// Echo implements the Echo interface.
3535
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
36-
klog.Debug("echo called")
36+
klog.Info("echo called")
3737
return &api.Response{Message: req.Message}, nil
3838
}
3939

‎governance/server/timeout/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type EchoImpl struct{}
3333

3434
// Echo implements the Echo interface.
3535
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
36-
klog.Debug("echo called")
36+
klog.Info("echo called")
3737
return &api.Response{Message: req.Message}, nil
3838
}
3939

‎loadbalancer/server/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Echo0Impl struct{}
3737

3838
// Echo implements the Echo interface.
3939
func (s *Echo0Impl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
40-
klog.Debug("echo0 called")
40+
klog.Info("echo0 called")
4141
return &api.Response{Message: req.Message}, nil
4242
}
4343

@@ -46,7 +46,7 @@ type Echo1Impl struct{}
4646

4747
// Echo implements the Echo interface.
4848
func (s *Echo1Impl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
49-
klog.Debug("echo1 called")
49+
klog.Info("echo1 called")
5050
return &api.Response{Message: req.Message}, nil
5151
}
5252

‎longconnection/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type EchoImpl struct{}
3333

3434
// Echo implements the Echo interface.
3535
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
36-
klog.Debug("echo called")
36+
klog.Info("echo called")
3737
return &api.Response{Message: req.Message}, nil
3838
}
3939

‎middleware/mymiddleware/mw.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ func CommonMiddleware(next endpoint.Endpoint) endpoint.Endpoint {
3737
return func(ctx context.Context, req, resp interface{}) (err error) {
3838
ri := rpcinfo.GetRPCInfo(ctx)
3939
// get real request
40-
klog.Debugf("real request: %+v\n", req.(args).GetFirstArgument())
40+
klog.Infof("real request: %+v\n", req.(args).GetFirstArgument())
4141
// get local service information
42-
klog.Debugf("local service name: %v\n", ri.From().ServiceName())
42+
klog.Infof("local service name: %v\n", ri.From().ServiceName())
4343
// get remote service information
44-
klog.Debugf("remote service name: %v, remote method: %v\n", ri.To().ServiceName(), ri.To().Method())
44+
klog.Infof("remote service name: %v, remote method: %v\n", ri.To().ServiceName(), ri.To().Method())
4545
if err := next(ctx, req, resp); err != nil {
4646
return err
4747
}
4848
// get real response
49-
klog.Debugf("real response: %+v\n", resp.(result).GetResult())
49+
klog.Infof("real response: %+v\n", resp.(result).GetResult())
5050
return nil
5151
}
5252
}
@@ -55,12 +55,12 @@ func ClientMiddleware(next endpoint.Endpoint) endpoint.Endpoint {
5555
return func(ctx context.Context, req, resp interface{}) (err error) {
5656
ri := rpcinfo.GetRPCInfo(ctx)
5757
// get timeout information
58-
klog.Debugf("rpc timeout: %v, readwrite timeout: %v\n", ri.Config().RPCTimeout(), ri.Config().ConnectTimeout())
58+
klog.Infof("rpc timeout: %v, readwrite timeout: %v\n", ri.Config().RPCTimeout(), ri.Config().ConnectTimeout())
5959
if err := next(ctx, req, resp); err != nil {
6060
return err
6161
}
6262
// get server information
63-
klog.Debugf("server address: %v\n", ri.To().Address())
63+
klog.Infof("server address: %v\n", ri.To().Address())
6464
return nil
6565
}
6666
}
@@ -69,7 +69,7 @@ func ServerMiddleware(next endpoint.Endpoint) endpoint.Endpoint {
6969
return func(ctx context.Context, req, resp interface{}) (err error) {
7070
ri := rpcinfo.GetRPCInfo(ctx)
7171
// get client information
72-
klog.Debugf("client address: %v\n", ri.From().Address())
72+
klog.Infof("client address: %v\n", ri.From().Address())
7373
if err := next(ctx, req, resp); err != nil {
7474
return err
7575
}

‎middleware/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type EchoImpl struct{}
3333

3434
// Echo implements the Echo interface.
3535
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
36-
klog.Debug("echo called")
36+
klog.Info("echo called")
3737
return &api.Response{Message: req.Message}, nil
3838
}
3939

‎protobuf/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type EchoImpl struct{}
3131

3232
// Echo implements the Echo interface.
3333
func (s *EchoImpl) Echo(ctx context.Context, req *pbapi.Request) (resp *pbapi.Response, err error) {
34-
klog.Debug("echo called")
34+
klog.Info("echo called")
3535
return &pbapi.Response{Message: req.Message}, nil
3636
}
3737

‎retry/failure/failure.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func NewDelayMW(delay time.Duration) endpoint.Middleware {
3434
time.Sleep(delay + 10*time.Millisecond)
3535
return next(ctx, req, resp)
3636
}
37-
klog.Debugf("this is a retry request")
37+
klog.Infof("this is a retry request")
3838
return next(ctx, req, resp)
3939
}
4040
}
@@ -46,7 +46,7 @@ func NewFailureMW() endpoint.Middleware {
4646
if _, exist := metainfo.GetPersistentValue(ctx, retry.TransitKey); !exist {
4747
return kerrors.ErrRPCTimeout.WithCause(errors.New("you shall not pass"))
4848
}
49-
klog.Debugf("this is a retry request")
49+
klog.Infof("this is a retry request")
5050
return next(ctx, req, resp)
5151
}
5252
}

‎retry/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type EchoImpl struct{}
3131

3232
// Echo implements the Echo interface.
3333
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
34-
klog.Debug("echo called")
34+
klog.Info("echo called")
3535
return &api.Response{Message: req.Message}, nil
3636
}
3737

‎streaming/client/main.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func doStreamRequestEcho(client echo.Client) error {
4545
if err != nil {
4646
return err
4747
}
48-
klog.Debugf("doStreamRequestEcho message received: %v\n", resp.Message)
48+
klog.Infof("doStreamRequestEcho message received: %v\n", resp.Message)
4949
return nil
5050
}
5151

@@ -59,12 +59,12 @@ func doStreamResponseEcho(client echo.Client) error {
5959
for {
6060
if resp, err := streamCli.Recv(); err != nil {
6161
if err == io.EOF {
62-
klog.Debug("doStreamResponseEcho receive done")
62+
klog.Info("doStreamResponseEcho receive done")
6363
return nil
6464
}
6565
return err
6666
} else {
67-
klog.Debugf("doStreamResponseEcho message received: %v\n", resp.Message)
67+
klog.Infof("doStreamResponseEcho message received: %v\n", resp.Message)
6868
}
6969
time.Sleep(time.Second)
7070
}
@@ -92,12 +92,12 @@ func doBidirectionalEcho(client echo.Client) error {
9292
for {
9393
if resp, err := streamCli.Recv(); err != nil {
9494
if err == io.EOF {
95-
klog.Debug("doBidirectionalEcho receive done")
95+
klog.Info("doBidirectionalEcho receive done")
9696
return nil
9797
}
9898
return err
9999
} else {
100-
klog.Debugf("doBidirectionalEcho message received: %v\n", resp.Message)
100+
klog.Infof("doBidirectionalEcho message received: %v\n", resp.Message)
101101
}
102102
time.Sleep(time.Second)
103103
}
@@ -110,19 +110,19 @@ func main() {
110110
if err != nil {
111111
klog.Fatal(err)
112112
}
113-
klog.Debug("doStreamRequestEcho start")
113+
klog.Info("doStreamRequestEcho start")
114114
if err := doStreamRequestEcho(client); err != nil {
115115
klog.Fatal(err)
116116
}
117-
klog.Debug("doStreamRequestEcho finish")
118-
klog.Debug("doStreamResponseEcho start")
117+
klog.Info("doStreamRequestEcho finish")
118+
klog.Info("doStreamResponseEcho start")
119119
if err := doStreamResponseEcho(client); err != nil {
120120
klog.Fatal(err)
121121
}
122-
klog.Debug("doStreamResponseEcho finish")
123-
klog.Debug("doBidirectionalEcho start")
122+
klog.Info("doStreamResponseEcho finish")
123+
klog.Info("doBidirectionalEcho start")
124124
if err := doBidirectionalEcho(client); err != nil {
125125
klog.Fatal(err)
126126
}
127-
klog.Debug("doBidirectionalEcho finish")
127+
klog.Info("doBidirectionalEcho finish")
128128
}

‎streaming/server/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type EchoImpl struct{}
3535

3636
// StreamRequestEcho implements the Echo interface.
3737
func (s *EchoImpl) StreamRequestEcho(stream pbapi.Echo_StreamRequestEchoServer) (err error) {
38-
klog.Debug("StreamRequestEcho called")
38+
klog.Info("StreamRequestEcho called")
3939
var msgs []string
4040
for {
4141
req, err := stream.Recv()
@@ -45,7 +45,7 @@ func (s *EchoImpl) StreamRequestEcho(stream pbapi.Echo_StreamRequestEchoServer)
4545
}
4646
return err
4747
}
48-
klog.Debugf("message received: %v\n", req.Message)
48+
klog.Infof("message received: %v\n", req.Message)
4949
msgs = append(msgs, req.Message)
5050
time.Sleep(time.Second)
5151
}
@@ -54,7 +54,7 @@ func (s *EchoImpl) StreamRequestEcho(stream pbapi.Echo_StreamRequestEchoServer)
5454

5555
// StreamResponseEcho implements the Echo interface.
5656
func (s *EchoImpl) StreamResponseEcho(req *pbapi.Request, stream pbapi.Echo_StreamResponseEchoServer) (err error) {
57-
klog.Debug("StreamResponseEcho called")
57+
klog.Info("StreamResponseEcho called")
5858
resp := &pbapi.Response{}
5959
for i := 0; i < 10; i++ {
6060
resp.Message = fmt.Sprintf("%v -> %dth response", req.Message, i)
@@ -69,7 +69,7 @@ func (s *EchoImpl) StreamResponseEcho(req *pbapi.Request, stream pbapi.Echo_Stre
6969

7070
// BidirectionalEcho implements the Echo interface.
7171
func (s *EchoImpl) BidirectionalEcho(stream pbapi.Echo_BidirectionalEchoServer) (err error) {
72-
klog.Debug("BidirectionalEcho called")
72+
klog.Info("BidirectionalEcho called")
7373
var eg errgroup.Group
7474
eg.Go(func() error {
7575
for {
@@ -80,7 +80,7 @@ func (s *EchoImpl) BidirectionalEcho(stream pbapi.Echo_BidirectionalEchoServer)
8080
}
8181
return err
8282
}
83-
klog.Debugf("message received: %v\n", req.Message)
83+
klog.Infof("message received: %v\n", req.Message)
8484
time.Sleep(time.Second)
8585
}
8686
})

‎tracer/server/opentracing/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type EchoImpl struct{}
3939

4040
// Echo implements the Echo interface.
4141
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
42-
klog.Debug("echo called")
42+
klog.Info("echo called")
4343
return &api.Response{Message: req.Message}, nil
4444
}
4545

0 commit comments

Comments
 (0)