embed: clean up structured logging calls

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee
2018-04-26 14:22:33 -07:00
parent f7f6fdeb52
commit c316e6773b
5 changed files with 345 additions and 268 deletions

View File

@@ -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) {