mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Address review comments a.d. logging.
This commit is contained in:
parent
fad6391745
commit
b47c5fcc12
@ -21,12 +21,11 @@ import (
|
||||
"os"
|
||||
|
||||
"go.etcd.io/etcd/client/pkg/v3/logutil"
|
||||
"go.uber.org/zap/zapgrpc"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"go.uber.org/zap/zapgrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
|
||||
// GetLogger returns the logger.
|
||||
|
@ -509,7 +509,14 @@ func (e *Etcd) servePeers() (err error) {
|
||||
ErrorLog: defaultLog.New(ioutil.Discard, "", 0), // do not log user error
|
||||
}
|
||||
go srv.Serve(m.Match(cmux.Any()))
|
||||
p.serve = func() error { return m.Serve() }
|
||||
p.serve = func() error {
|
||||
e.cfg.logger.Info(
|
||||
"cmux::serve",
|
||||
zap.String("address", u),
|
||||
zap.String("cmuxp", fmt.Sprintf("%p", m)),
|
||||
)
|
||||
return m.Serve()
|
||||
}
|
||||
p.close = func(ctx context.Context) error {
|
||||
// gracefully shutdown http.Server
|
||||
// close open listeners, idle connections
|
||||
@ -517,12 +524,16 @@ func (e *Etcd) servePeers() (err error) {
|
||||
e.cfg.logger.Info(
|
||||
"stopping serving peer traffic",
|
||||
zap.String("address", u),
|
||||
zap.String("cmuxp", fmt.Sprintf("%p", m)),
|
||||
)
|
||||
stopServers(ctx, &servers{secure: peerTLScfg != nil, grpc: gs, http: srv})
|
||||
e.cfg.logger.Info(
|
||||
"stopped serving peer traffic",
|
||||
zap.String("address", u),
|
||||
zap.String("cmuxp", fmt.Sprintf("%p", m)),
|
||||
)
|
||||
m.Close()
|
||||
e.cfg.logger.Info("Closed", zap.String("cmuxp", fmt.Sprintf("%p", m)))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,9 @@ func startEtcdOrProxyV2(args []string) {
|
||||
|
||||
err := cfg.parse(args[1:])
|
||||
lg := cfg.ec.GetLogger()
|
||||
cfg.ec.SetupGlobalLoggers()
|
||||
|
||||
// If we failed to parse the whole configuration, print the error using
|
||||
// preferably the resolved logger from the config,
|
||||
// but if does not exists, create a new temporary logger.
|
||||
if lg == nil {
|
||||
var zapError error
|
||||
// use this logger
|
||||
@ -78,6 +79,8 @@ func startEtcdOrProxyV2(args []string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cfg.ec.SetupGlobalLoggers()
|
||||
|
||||
defer func() {
|
||||
logger := cfg.ec.GetLogger()
|
||||
if logger != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user