mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
embed: clean up structured logging calls
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
@@ -28,6 +28,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"github.com/coreos/etcd/etcdserver"
|
||||
"github.com/coreos/etcd/etcdserver/api/etcdhttp"
|
||||
"github.com/coreos/etcd/etcdserver/api/v2http"
|
||||
@@ -273,6 +275,23 @@ func (e *Etcd) Config() Config {
|
||||
// Client requests will be terminated with request timeout.
|
||||
// After timeout, enforce remaning requests be closed immediately.
|
||||
func (e *Etcd) Close() {
|
||||
fields := []zapcore.Field{
|
||||
zap.String("name", e.cfg.Name),
|
||||
zap.String("data-dir", e.cfg.Dir),
|
||||
zap.Strings("advertise-peer-urls", e.cfg.getAPURLs()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getACURLs()),
|
||||
}
|
||||
lg := e.GetLogger()
|
||||
if lg != nil {
|
||||
lg.Info("closing etcd server", fields...)
|
||||
}
|
||||
defer func() {
|
||||
if lg != nil {
|
||||
lg.Info("closed etcd server", fields...)
|
||||
lg.Sync()
|
||||
}
|
||||
}()
|
||||
|
||||
e.closeOnce.Do(func() { close(e.stopc) })
|
||||
|
||||
// close client requests with request timeout
|
||||
@@ -315,11 +334,6 @@ func (e *Etcd) Close() {
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
lg := e.GetLogger()
|
||||
if lg != nil {
|
||||
lg.Sync()
|
||||
}
|
||||
}
|
||||
|
||||
func stopServers(ctx context.Context, ss *servers) {
|
||||
|
||||
Reference in New Issue
Block a user