fix log print (#1021)

pull/1023/head
Tony Chen 3 years ago committed by GitHub
parent 50e3dea2ee
commit d23a91650a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      examples/helloworld/client/main.go

@ -37,15 +37,15 @@ func callHTTP() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
logger.Log(log.LevelInfo, fmt.Sprintf("[http] SayHello %s\n", reply.Message)) logger.Log(log.LevelInfo, "msg", fmt.Sprintf("[http] SayHello %s\n", reply.Message))
// returns error // returns error
reply, err = client.SayHello(context.Background(), &pb.HelloRequest{Name: "error"}) reply, err = client.SayHello(context.Background(), &pb.HelloRequest{Name: "error"})
if err != nil { if err != nil {
logger.Log(log.LevelInfo, fmt.Sprintf("[http] SayHello error: %v\n", err)) logger.Log(log.LevelInfo, "msg", fmt.Sprintf("[http] SayHello error: %v\n", err))
} }
if errors.IsBadRequest(err) { if errors.IsBadRequest(err) {
logger.Log(log.LevelInfo, fmt.Sprintf("[http] SayHello error is invalid argument: %v\n", err)) logger.Log(log.LevelInfo, "msg", fmt.Sprintf("[http] SayHello error is invalid argument: %v\n", err))
} }
} }
@ -69,14 +69,14 @@ func callGRPC() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
logger.Log(log.LevelInfo, fmt.Sprintf("[grpc] SayHello %+v", reply)) logger.Log(log.LevelInfo, "msg", fmt.Sprintf("[grpc] SayHello %+v", reply))
// returns error // returns error
_, err = client.SayHello(context.Background(), &pb.HelloRequest{Name: "error"}) _, err = client.SayHello(context.Background(), &pb.HelloRequest{Name: "error"})
if err != nil { if err != nil {
logger.Log(log.LevelInfo, fmt.Sprintf("[grpc] SayHello error: %v", err)) logger.Log(log.LevelInfo, "msg", fmt.Sprintf("[grpc] SayHello error: %v", err))
} }
if errors.IsBadRequest(err) { if errors.IsBadRequest(err) {
logger.Log(log.LevelInfo, fmt.Sprintf("[grpc] SayHello error is invalid argument: %v", err)) logger.Log(log.LevelInfo, "msg", fmt.Sprintf("[grpc] SayHello error is invalid argument: %v", err))
} }
} }

Loading…
Cancel
Save