Skip to content

Commit

Permalink
use the correct log library to print log messages
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
  • Loading branch information
ahrtr committed Jan 18, 2024
1 parent 071cb43 commit 9009d3e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions embed/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ func (sctx *serveCtx) serve(
logger := defaultLog.New(ioutil.Discard, "etcdhttp", 0)
<-s.ReadyNotify()

if sctx.lg == nil {
if sctx.lg != nil {
sctx.lg.Info("ready to serve client requests")
} else {
plog.Info("ready to serve client requests")
}

Expand All @@ -118,7 +120,11 @@ func (sctx *serveCtx) serve(
// GRPC gateway connects to grpc server via connection provided by grpc dial.
gwmux, err = sctx.registerGateway(grpcDialForRestGatewayBackends)
if err != nil {
sctx.lg.Error("registerGateway failed", zap.Error(err))
if sctx.lg != nil {
sctx.lg.Error("registerGateway failed", zap.Error(err))
} else {
plog.Errorf("registerGateway failed: %v", err)
}
return err
}
}
Expand All @@ -142,7 +148,12 @@ func (sctx *serveCtx) serve(
ErrorLog: logger, // do not log user error
}
if err := configureHttpServer(srv, s.Cfg); err != nil {
sctx.lg.Error("Configure http server failed", zap.Error(err))
if sctx.lg != nil {
sctx.lg.Error("Configure http server failed", zap.Error(err))
} else {
plog.Errorf("Configure http server failed: %v", err)
}

return err
}
}
Expand Down Expand Up @@ -253,7 +264,11 @@ func (sctx *serveCtx) serve(
ErrorLog: logger, // do not log user error
}
if err := configureHttpServer(srv, s.Cfg); err != nil {
sctx.lg.Error("Configure https server failed", zap.Error(err))
if sctx.lg != nil {
sctx.lg.Error("Configure https server failed", zap.Error(err))
} else {
plog.Errorf("Configure https server failed: %v", err)
}
return err
}
}
Expand Down

0 comments on commit 9009d3e

Please sign in to comment.