Browse code

swap logrus types for their containerd/logs aliases

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/07/31 00:18:56
Showing 51 changed files
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"github.com/containerd/containerd/log"
10 10
 	"github.com/docker/distribution/registry/api/errcode"
11 11
 	"github.com/docker/docker/errdefs"
12
-	"github.com/sirupsen/logrus"
13 12
 	"google.golang.org/grpc/codes"
14 13
 	"google.golang.org/grpc/status"
15 14
 )
... ...
@@ -21,7 +20,7 @@ type causer interface {
21 21
 // FromError retrieves status code from error message.
22 22
 func FromError(err error) int {
23 23
 	if err == nil {
24
-		log.G(context.TODO()).WithFields(logrus.Fields{"error": err}).Error("unexpected HTTP error handling")
24
+		log.G(context.TODO()).WithError(err).Error("unexpected HTTP error handling")
25 25
 		return http.StatusInternalServerError
26 26
 	}
27 27
 
... ...
@@ -67,10 +66,11 @@ func FromError(err error) int {
67 67
 			return FromError(e.Cause())
68 68
 		}
69 69
 
70
-		log.G(context.TODO()).WithFields(logrus.Fields{
70
+		log.G(context.TODO()).WithFields(log.Fields{
71 71
 			"module":     "api",
72
+			"error":      err,
72 73
 			"error_type": fmt.Sprintf("%T", err),
73
-		}).Debugf("FIXME: Got an API for which error does not match any expected type!!!: %+v", err)
74
+		}).Debug("FIXME: Got an API for which error does not match any expected type!!!")
74 75
 	}
75 76
 
76 77
 	if statusCode == 0 {
... ...
@@ -1,9 +1,9 @@
1 1
 package server // import "github.com/docker/docker/api/server"
2 2
 
3 3
 import (
4
+	"github.com/containerd/containerd/log"
4 5
 	"github.com/docker/docker/api/server/httputils"
5 6
 	"github.com/docker/docker/api/server/middleware"
6
-	"github.com/sirupsen/logrus"
7 7
 )
8 8
 
9 9
 // handlerWithGlobalMiddlewares wraps the handler function for a request with
... ...
@@ -16,7 +16,7 @@ func (s *Server) handlerWithGlobalMiddlewares(handler httputils.APIFunc) httputi
16 16
 		next = m.WrapHandler(next)
17 17
 	}
18 18
 
19
-	if logrus.GetLevel() == logrus.DebugLevel {
19
+	if log.GetLevel() == log.DebugLevel {
20 20
 		next = middleware.DebugRequestMiddleware(next)
21 21
 	}
22 22
 
... ...
@@ -16,7 +16,6 @@ import (
16 16
 	"github.com/docker/docker/api/types/versions"
17 17
 	"github.com/docker/docker/errdefs"
18 18
 	"github.com/pkg/errors"
19
-	"github.com/sirupsen/logrus"
20 19
 )
21 20
 
22 21
 func (sr *swarmRouter) initCluster(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
... ...
@@ -195,7 +194,7 @@ func (sr *swarmRouter) getService(ctx context.Context, w http.ResponseWriter, r
195 195
 
196 196
 	service, err := sr.backend.GetService(vars["id"], insertDefaults)
197 197
 	if err != nil {
198
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
198
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
199 199
 			"error":      err,
200 200
 			"service-id": vars["id"],
201 201
 		}).Debug("Error getting service")
... ...
@@ -231,7 +230,7 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter,
231 231
 
232 232
 	resp, err := sr.backend.CreateService(service, encodedAuth, queryRegistry)
233 233
 	if err != nil {
234
-		log.G(ctx).WithFields(logrus.Fields{
234
+		log.G(ctx).WithFields(log.Fields{
235 235
 			"error":        err,
236 236
 			"service-name": service.Name,
237 237
 		}).Debug("Error creating service")
... ...
@@ -270,7 +269,7 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter,
270 270
 
271 271
 	resp, err := sr.backend.UpdateService(vars["id"], version, service, flags, queryRegistry)
272 272
 	if err != nil {
273
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
273
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
274 274
 			"error":      err,
275 275
 			"service-id": vars["id"],
276 276
 		}).Debug("Error updating service")
... ...
@@ -281,7 +280,7 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter,
281 281
 
282 282
 func (sr *swarmRouter) removeService(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
283 283
 	if err := sr.backend.RemoveService(vars["id"]); err != nil {
284
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
284
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
285 285
 			"error":      err,
286 286
 			"service-id": vars["id"],
287 287
 		}).Debug("Error removing service")
... ...
@@ -335,7 +334,7 @@ func (sr *swarmRouter) getNodes(ctx context.Context, w http.ResponseWriter, r *h
335 335
 func (sr *swarmRouter) getNode(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
336 336
 	node, err := sr.backend.GetNode(vars["id"])
337 337
 	if err != nil {
338
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
338
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
339 339
 			"error":   err,
340 340
 			"node-id": vars["id"],
341 341
 		}).Debug("Error getting node")
... ...
@@ -359,7 +358,7 @@ func (sr *swarmRouter) updateNode(ctx context.Context, w http.ResponseWriter, r
359 359
 	}
360 360
 
361 361
 	if err := sr.backend.UpdateNode(vars["id"], version, node); err != nil {
362
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
362
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
363 363
 			"error":   err,
364 364
 			"node-id": vars["id"],
365 365
 		}).Debug("Error updating node")
... ...
@@ -376,7 +375,7 @@ func (sr *swarmRouter) removeNode(ctx context.Context, w http.ResponseWriter, r
376 376
 	force := httputils.BoolValue(r, "force")
377 377
 
378 378
 	if err := sr.backend.RemoveNode(vars["id"], force); err != nil {
379
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
379
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
380 380
 			"error":   err,
381 381
 			"node-id": vars["id"],
382 382
 		}).Debug("Error removing node")
... ...
@@ -406,7 +405,7 @@ func (sr *swarmRouter) getTasks(ctx context.Context, w http.ResponseWriter, r *h
406 406
 func (sr *swarmRouter) getTask(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
407 407
 	task, err := sr.backend.GetTask(vars["id"])
408 408
 	if err != nil {
409
-		log.G(ctx).WithContext(ctx).WithFields(logrus.Fields{
409
+		log.G(ctx).WithContext(ctx).WithFields(log.Fields{
410 410
 			"error":   err,
411 411
 			"task-id": vars["id"],
412 412
 		}).Debug("Error getting task")
... ...
@@ -3,21 +3,21 @@ package debug // import "github.com/docker/docker/cli/debug"
3 3
 import (
4 4
 	"os"
5 5
 
6
-	"github.com/sirupsen/logrus"
6
+	"github.com/containerd/containerd/log"
7 7
 )
8 8
 
9 9
 // Enable sets the DEBUG env var to true
10 10
 // and makes the logger to log at debug level.
11 11
 func Enable() {
12 12
 	os.Setenv("DEBUG", "1")
13
-	logrus.SetLevel(logrus.DebugLevel)
13
+	_ = log.SetLevel("debug")
14 14
 }
15 15
 
16 16
 // Disable sets the DEBUG env var to false
17 17
 // and makes the logger to log at info level.
18 18
 func Disable() {
19 19
 	os.Setenv("DEBUG", "")
20
-	logrus.SetLevel(logrus.InfoLevel)
20
+	_ = log.SetLevel("info")
21 21
 }
22 22
 
23 23
 // IsEnabled checks whether the debug flag is set or not.
... ...
@@ -4,30 +4,30 @@ import (
4 4
 	"os"
5 5
 	"testing"
6 6
 
7
-	"github.com/sirupsen/logrus"
7
+	"github.com/containerd/containerd/log"
8 8
 )
9 9
 
10 10
 func TestEnable(t *testing.T) {
11
-	defer func() {
12
-		os.Setenv("DEBUG", "")
13
-		logrus.SetLevel(logrus.InfoLevel)
14
-	}()
11
+	t.Cleanup(func() {
12
+		_ = os.Setenv("DEBUG", "")
13
+		_ = log.SetLevel("info")
14
+	})
15 15
 	Enable()
16
-	if os.Getenv("DEBUG") != "1" {
17
-		t.Fatalf("expected DEBUG=1, got %s", os.Getenv("DEBUG"))
16
+	if debug := os.Getenv("DEBUG"); debug != "1" {
17
+		t.Fatalf("expected DEBUG=1, got %s", debug)
18 18
 	}
19
-	if logrus.GetLevel() != logrus.DebugLevel {
20
-		t.Fatalf("expected log level %v, got %v", logrus.DebugLevel, logrus.GetLevel())
19
+	if lvl := log.GetLevel(); lvl != log.DebugLevel {
20
+		t.Fatalf("expected log level %v, got %v", log.DebugLevel, lvl)
21 21
 	}
22 22
 }
23 23
 
24 24
 func TestDisable(t *testing.T) {
25 25
 	Disable()
26
-	if os.Getenv("DEBUG") != "" {
27
-		t.Fatalf(`expected DEBUG="", got %s`, os.Getenv("DEBUG"))
26
+	if debug := os.Getenv("DEBUG"); debug != "" {
27
+		t.Fatalf(`expected DEBUG="", got %s`, debug)
28 28
 	}
29
-	if logrus.GetLevel() != logrus.InfoLevel {
30
-		t.Fatalf("expected log level %v, got %v", logrus.InfoLevel, logrus.GetLevel())
29
+	if lvl := log.GetLevel(); lvl != log.InfoLevel {
30
+		t.Fatalf("expected log level %v, got %v", log.InfoLevel, lvl)
31 31
 	}
32 32
 }
33 33
 
... ...
@@ -47,7 +47,6 @@ import (
47 47
 	dopts "github.com/docker/docker/opts"
48 48
 	"github.com/docker/docker/pkg/authorization"
49 49
 	"github.com/docker/docker/pkg/homedir"
50
-	"github.com/docker/docker/pkg/jsonmessage"
51 50
 	"github.com/docker/docker/pkg/pidfile"
52 51
 	"github.com/docker/docker/pkg/plugingetter"
53 52
 	"github.com/docker/docker/pkg/rootless"
... ...
@@ -305,9 +304,9 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
305 305
 			defer apiWG.Done()
306 306
 			log.G(ctx).Infof("API listen on %s", ls.Addr())
307 307
 			if err := httpServer.Serve(ls); err != http.ErrServerClosed {
308
-				log.G(ctx).WithFields(logrus.Fields{
309
-					logrus.ErrorKey: err,
310
-					"listener":      ls.Addr(),
308
+				log.G(ctx).WithFields(log.Fields{
309
+					"error":    err,
310
+					"listener": ls.Addr(),
311 311
 				}).Error("ServeAPI error")
312 312
 
313 313
 				select {
... ...
@@ -861,37 +860,31 @@ func systemContainerdRunning(honorXDG bool) (string, bool, error) {
861 861
 	return addr, err == nil, nil
862 862
 }
863 863
 
864
-// configureDaemonLogs sets the logrus logging level and formatting. It expects
864
+// configureDaemonLogs sets the logging level and formatting. It expects
865 865
 // the passed configuration to already be validated, and ignores invalid options.
866 866
 func configureDaemonLogs(conf *config.Config) {
867
-	if conf.LogLevel != "" {
868
-		lvl, err := logrus.ParseLevel(conf.LogLevel)
869
-		if err == nil {
870
-			logrus.SetLevel(lvl)
871
-		}
872
-	} else {
873
-		logrus.SetLevel(logrus.InfoLevel)
874
-	}
875
-	logFormat := conf.LogFormat
876
-	if logFormat == "" {
877
-		logFormat = log.TextFormat
878
-	}
879
-	var formatter logrus.Formatter
880
-	switch logFormat {
867
+	switch conf.LogFormat {
881 868
 	case log.JSONFormat:
882
-		formatter = &logrus.JSONFormatter{
883
-			TimestampFormat: jsonmessage.RFC3339NanoFixed,
884
-		}
885
-	case log.TextFormat:
886
-		formatter = &logrus.TextFormatter{
887
-			TimestampFormat: jsonmessage.RFC3339NanoFixed,
869
+		logrus.SetFormatter(&logrus.JSONFormatter{
870
+			TimestampFormat: log.RFC3339NanoFixed,
871
+		})
872
+	case log.TextFormat, "":
873
+		logrus.SetFormatter(&logrus.TextFormatter{
874
+			TimestampFormat: log.RFC3339NanoFixed,
888 875
 			DisableColors:   conf.RawLogs,
889 876
 			FullTimestamp:   true,
890
-		}
877
+		})
891 878
 	default:
892
-		panic("unsupported log format " + logFormat)
879
+		panic("unsupported log format " + conf.LogFormat)
880
+	}
881
+
882
+	logLevel := conf.LogLevel
883
+	if logLevel == "" {
884
+		logLevel = "info"
885
+	}
886
+	if err := log.SetLevel(logLevel); err != nil {
887
+		log.G(context.TODO()).WithError(err).Warn("configure log level")
893 888
 	}
894
-	logrus.SetFormatter(formatter)
895 889
 }
896 890
 
897 891
 func configureProxyEnv(conf *config.Config) {
... ...
@@ -911,7 +904,7 @@ func configureProxyEnv(conf *config.Config) {
911 911
 
912 912
 func overrideProxyEnv(name, val string) {
913 913
 	if oldVal := os.Getenv(name); oldVal != "" && oldVal != val {
914
-		log.G(context.TODO()).WithFields(logrus.Fields{
914
+		log.G(context.TODO()).WithFields(log.Fields{
915 915
 			"name":      name,
916 916
 			"old-value": config.MaskCredentials(oldVal),
917 917
 			"new-value": config.MaskCredentials(val),
... ...
@@ -211,14 +211,15 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
211 211
 func TestConfigureDaemonLogs(t *testing.T) {
212 212
 	conf := &config.Config{}
213 213
 	configureDaemonLogs(conf)
214
-	assert.Check(t, is.Equal(logrus.InfoLevel, logrus.GetLevel()))
215
-
216
-	conf.LogLevel = "warn"
217
-	configureDaemonLogs(conf)
218
-	assert.Check(t, is.Equal(logrus.WarnLevel, logrus.GetLevel()))
214
+	assert.Check(t, is.Equal(log.InfoLevel, log.GetLevel()))
219 215
 
220 216
 	// log level should not be changed when passing an invalid value
221 217
 	conf.LogLevel = "foobar"
222 218
 	configureDaemonLogs(conf)
223
-	assert.Check(t, is.Equal(logrus.WarnLevel, logrus.GetLevel()))
219
+	assert.Check(t, is.Equal(log.InfoLevel, log.GetLevel()))
220
+
221
+	conf.LogLevel = "warn"
222
+	configureDaemonLogs(conf)
223
+	// TODO (thaJeztah): add more aliases in log package
224
+	assert.Check(t, is.Equal(logrus.WarnLevel, log.GetLevel()))
224 225
 }
... ...
@@ -6,9 +6,9 @@ import (
6 6
 	"os/signal"
7 7
 	"syscall"
8 8
 
9
+	"github.com/containerd/containerd/log"
9 10
 	"github.com/docker/docker/daemon/config"
10 11
 	"github.com/docker/docker/dockerversion"
11
-	"github.com/docker/docker/pkg/jsonmessage"
12 12
 	"github.com/docker/docker/pkg/reexec"
13 13
 	"github.com/docker/docker/pkg/rootless"
14 14
 	"github.com/moby/buildkit/util/apicaps"
... ...
@@ -84,7 +84,7 @@ func main() {
84 84
 
85 85
 	// initial log formatting; this setting is updated after the daemon configuration is loaded.
86 86
 	logrus.SetFormatter(&logrus.TextFormatter{
87
-		TimestampFormat: jsonmessage.RFC3339NanoFixed,
87
+		TimestampFormat: log.RFC3339NanoFixed,
88 88
 		FullTimestamp:   true,
89 89
 	})
90 90
 
... ...
@@ -62,7 +62,7 @@ func NewController(backend Backend, t *api.Task) (*Controller, error) {
62 62
 		backend:   backend,
63 63
 		spec:      spec,
64 64
 		serviceID: t.ServiceID,
65
-		logger: log.G(context.TODO()).WithFields(logrus.Fields{
65
+		logger: log.G(context.TODO()).WithFields(log.Fields{
66 66
 			"controller": "plugin",
67 67
 			"task":       t.ID,
68 68
 			"plugin":     spec.Name,
... ...
@@ -11,6 +11,7 @@ import (
11 11
 	"syscall"
12 12
 	"time"
13 13
 
14
+	"github.com/containerd/containerd/log"
14 15
 	"github.com/docker/distribution/reference"
15 16
 	"github.com/docker/docker/api/types"
16 17
 	"github.com/docker/docker/api/types/backend"
... ...
@@ -27,10 +28,9 @@ import (
27 27
 	gogotypes "github.com/gogo/protobuf/types"
28 28
 	"github.com/moby/swarmkit/v2/agent/exec"
29 29
 	"github.com/moby/swarmkit/v2/api"
30
-	"github.com/moby/swarmkit/v2/log"
30
+	swarmlog "github.com/moby/swarmkit/v2/log"
31 31
 	"github.com/opencontainers/go-digest"
32 32
 	"github.com/pkg/errors"
33
-	"github.com/sirupsen/logrus"
34 33
 	"golang.org/x/time/rate"
35 34
 )
36 35
 
... ...
@@ -95,7 +95,7 @@ func (c *containerAdapter) pullImage(ctx context.Context) error {
95 95
 	authConfig := &registry.AuthConfig{}
96 96
 	if encodedAuthConfig != "" {
97 97
 		if err := json.NewDecoder(base64.NewDecoder(base64.URLEncoding, strings.NewReader(encodedAuthConfig))).Decode(authConfig); err != nil {
98
-			log.G(ctx).Warnf("invalid authconfig: %v", err)
98
+			swarmlog.G(ctx).Warnf("invalid authconfig: %v", err)
99 99
 		}
100 100
 	}
101 101
 
... ...
@@ -121,19 +121,19 @@ func (c *containerAdapter) pullImage(ctx context.Context) error {
121 121
 			}
122 122
 			return err
123 123
 		}
124
-		l := log.G(ctx)
124
+		l := swarmlog.G(ctx)
125 125
 		// limit pull progress logs unless the status changes
126 126
 		if spamLimiter.Allow() || lastStatus != m["status"] {
127 127
 			// if we have progress details, we have everything we need
128 128
 			if progress, ok := m["progressDetail"].(map[string]interface{}); ok {
129 129
 				// first, log the image and status
130
-				l = l.WithFields(logrus.Fields{
130
+				l = l.WithFields(log.Fields{
131 131
 					"image":  c.container.image(),
132 132
 					"status": m["status"],
133 133
 				})
134 134
 				// then, if we have progress, log the progress
135 135
 				if progress["current"] != nil && progress["total"] != nil {
136
-					l = l.WithFields(logrus.Fields{
136
+					l = l.WithFields(log.Fields{
137 137
 						"current": progress["current"],
138 138
 						"total":   progress["total"],
139 139
 					})
... ...
@@ -240,7 +240,7 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error {
240 240
 			case errors.As(err, &errNoSuchNetwork):
241 241
 				continue
242 242
 			default:
243
-				log.G(ctx).Errorf("network %s remove failed: %v", name, err)
243
+				swarmlog.G(ctx).Errorf("network %s remove failed: %v", name, err)
244 244
 				return err
245 245
 			}
246 246
 		}
... ...
@@ -374,7 +374,7 @@ func (c *containerAdapter) inspect(ctx context.Context) (types.ContainerJSON, er
374 374
 // events issues a call to the events API and returns a channel with all
375 375
 // events. The stream of events can be shutdown by cancelling the context.
376 376
 func (c *containerAdapter) events(ctx context.Context) <-chan events.Message {
377
-	log.G(ctx).Debugf("waiting on events")
377
+	swarmlog.G(ctx).Debugf("waiting on events")
378 378
 	buffer, l := c.backend.SubscribeToEvents(time.Time{}, time.Time{}, c.container.eventFilter())
379 379
 	eventsq := make(chan events.Message, len(buffer))
380 380
 
... ...
@@ -390,7 +390,7 @@ func (c *containerAdapter) events(ctx context.Context) <-chan events.Message {
390 390
 			case ev := <-l:
391 391
 				jev, ok := ev.(events.Message)
392 392
 				if !ok {
393
-					log.G(ctx).Warnf("unexpected event message: %q", ev)
393
+					swarmlog.G(ctx).Warnf("unexpected event message: %q", ev)
394 394
 					continue
395 395
 				}
396 396
 				select {
... ...
@@ -485,7 +485,7 @@ func (c *containerAdapter) waitClusterVolumes(ctx context.Context) error {
485 485
 			}
486 486
 		}
487 487
 	}
488
-	log.G(ctx).Debug("volumes ready")
488
+	swarmlog.G(ctx).Debug("volumes ready")
489 489
 	return nil
490 490
 }
491 491
 
... ...
@@ -7,6 +7,7 @@ import (
7 7
 	"strings"
8 8
 	"sync"
9 9
 
10
+	"github.com/containerd/containerd/log"
10 11
 	"github.com/docker/docker/api/types"
11 12
 	"github.com/docker/docker/api/types/filters"
12 13
 	"github.com/docker/docker/api/types/network"
... ...
@@ -21,10 +22,9 @@ import (
21 21
 	"github.com/moby/swarmkit/v2/agent/exec"
22 22
 	"github.com/moby/swarmkit/v2/api"
23 23
 	"github.com/moby/swarmkit/v2/api/naming"
24
-	"github.com/moby/swarmkit/v2/log"
24
+	swarmlog "github.com/moby/swarmkit/v2/log"
25 25
 	"github.com/moby/swarmkit/v2/template"
26 26
 	"github.com/pkg/errors"
27
-	"github.com/sirupsen/logrus"
28 27
 )
29 28
 
30 29
 type executor struct {
... ...
@@ -160,8 +160,7 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error {
160 160
 		if na == nil || na.Network == nil || len(na.Addresses) == 0 {
161 161
 			// this should not happen, but we got a panic here and don't have a
162 162
 			// good idea about what the underlying data structure looks like.
163
-			log.G(ctx).WithField("NetworkAttachment", fmt.Sprintf("%#v", na)).
164
-				Warnf("skipping nil or malformed node network attachment entry")
163
+			swarmlog.G(ctx).WithField("NetworkAttachment", fmt.Sprintf("%#v", na)).Warn("skipping nil or malformed node network attachment entry")
165 164
 			continue
166 165
 		}
167 166
 
... ...
@@ -192,8 +191,7 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error {
192 192
 			// same thing as above, check sanity of the attachments so we don't
193 193
 			// get a panic.
194 194
 			if na == nil || na.Network == nil || len(na.Addresses) == 0 {
195
-				log.G(ctx).WithField("NetworkAttachment", fmt.Sprintf("%#v", na)).
196
-					Warnf("skipping nil or malformed node network attachment entry")
195
+				swarmlog.G(ctx).WithField("NetworkAttachment", fmt.Sprintf("%#v", na)).Warn("skipping nil or malformed node network attachment entry")
197 196
 				continue
198 197
 			}
199 198
 
... ...
@@ -262,19 +260,16 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error {
262 262
 			// just to log an appropriate, informative error. i'm unsure if
263 263
 			// this can ever actually occur, but we need to know if it does.
264 264
 			if gone {
265
-				log.G(ctx).Warnf("network %s should be removed, but still has active attachments", nw)
265
+				swarmlog.G(ctx).Warnf("network %s should be removed, but still has active attachments", nw)
266 266
 			} else {
267
-				log.G(ctx).Warnf(
268
-					"network %s should have its node LB IP changed, but cannot be removed because of active attachments",
269
-					nw,
270
-				)
267
+				swarmlog.G(ctx).Warnf("network %s should have its node LB IP changed, but cannot be removed because of active attachments", nw)
271 268
 			}
272 269
 			continue
273 270
 		case errors.As(err, &errNoSuchNetwork):
274 271
 			// NoSuchNetworkError indicates the network is already gone.
275 272
 			continue
276 273
 		default:
277
-			log.G(ctx).Errorf("network %s remove failed: %v", nw, err)
274
+			swarmlog.G(ctx).Errorf("network %s remove failed: %v", nw, err)
278 275
 		}
279 276
 	}
280 277
 
... ...
@@ -301,7 +296,7 @@ func (e *executor) Controller(t *api.Task) (exec.Controller, error) {
301 301
 	var ctlr exec.Controller
302 302
 	switch r := t.Spec.GetRuntime().(type) {
303 303
 	case *api.TaskSpec_Generic:
304
-		log.G(context.TODO()).WithFields(logrus.Fields{
304
+		swarmlog.G(context.TODO()).WithFields(log.Fields{
305 305
 			"kind":     r.Generic.Kind,
306 306
 			"type_url": r.Generic.Payload.TypeUrl,
307 307
 		}).Debug("custom runtime requested")
... ...
@@ -23,7 +23,6 @@ import (
23 23
 	"github.com/moby/sys/mount"
24 24
 	"github.com/opencontainers/selinux/go-selinux/label"
25 25
 	"github.com/pkg/errors"
26
-	"github.com/sirupsen/logrus"
27 26
 	"golang.org/x/sys/unix"
28 27
 )
29 28
 
... ...
@@ -200,7 +199,7 @@ func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
200 200
 			return errors.Wrap(err, "error creating secret mount path")
201 201
 		}
202 202
 
203
-		log.G(context.TODO()).WithFields(logrus.Fields{
203
+		log.G(context.TODO()).WithFields(log.Fields{
204 204
 			"name": s.File.Name,
205 205
 			"path": fPath,
206 206
 		}).Debug("injecting secret")
... ...
@@ -251,7 +250,7 @@ func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
251 251
 			return errors.Wrap(err, "error creating config mount path")
252 252
 		}
253 253
 
254
-		log.G(context.TODO()).WithFields(logrus.Fields{
254
+		log.G(context.TODO()).WithFields(log.Fields{
255 255
 			"name": configRef.File.Name,
256 256
 			"path": fPath,
257 257
 		}).Debug("injecting config")
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"github.com/docker/docker/libnetwork"
12 12
 	"github.com/docker/docker/pkg/system"
13 13
 	"github.com/pkg/errors"
14
-	"github.com/sirupsen/logrus"
15 14
 )
16 15
 
17 16
 func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
... ...
@@ -61,7 +60,7 @@ func (daemon *Daemon) setupConfigDir(c *container.Container) (setupErr error) {
61 61
 		if err != nil {
62 62
 			return errors.Wrap(err, "error getting config file path for container")
63 63
 		}
64
-		log := log.G(context.TODO()).WithFields(logrus.Fields{"name": configRef.File.Name, "path": fPath})
64
+		log := log.G(context.TODO()).WithFields(log.Fields{"name": configRef.File.Name, "path": fPath})
65 65
 
66 66
 		log.Debug("injecting config")
67 67
 		config, err := c.DependencyStore.Configs().Get(configRef.ConfigID)
... ...
@@ -131,7 +130,7 @@ func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
131 131
 		if err != nil {
132 132
 			return err
133 133
 		}
134
-		log.G(context.TODO()).WithFields(logrus.Fields{
134
+		log.G(context.TODO()).WithFields(log.Fields{
135 135
 			"name": s.File.Name,
136 136
 			"path": fPath,
137 137
 		}).Debug("injecting secret")
... ...
@@ -12,7 +12,6 @@ import (
12 12
 	"github.com/docker/docker/image"
13 13
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
14 14
 	"github.com/pkg/errors"
15
-	"github.com/sirupsen/logrus"
16 15
 )
17 16
 
18 17
 // Children returns a slice of image ID which rootfs is a superset of the
... ...
@@ -36,10 +35,10 @@ func (i *ImageService) Children(ctx context.Context, id image.ID) ([]image.ID, e
36 36
 		rootfs, err := platformRootfs(ctx, cs, target, platform)
37 37
 		if err != nil {
38 38
 			if !cerrdefs.IsNotFound(err) {
39
-				log.G(ctx).WithFields(logrus.Fields{
40
-					logrus.ErrorKey: err,
41
-					"image":         target.Digest,
42
-					"platform":      platform,
39
+				log.G(ctx).WithFields(log.Fields{
40
+					"error":    err,
41
+					"image":    target.Digest,
42
+					"platform": platform,
43 43
 				}).Warning("failed to get platform-specific rootfs")
44 44
 			}
45 45
 			continue
... ...
@@ -60,10 +59,10 @@ func (i *ImageService) Children(ctx context.Context, id image.ID) ([]image.ID, e
60 60
 			rootfs, err := platformRootfs(ctx, cs, img.Target, platform)
61 61
 			if err != nil {
62 62
 				if !cerrdefs.IsNotFound(err) {
63
-					log.G(ctx).WithFields(logrus.Fields{
64
-						logrus.ErrorKey: err,
65
-						"image":         img.Target.Digest,
66
-						"platform":      platform,
63
+					log.G(ctx).WithFields(log.Fields{
64
+						"error":    err,
65
+						"image":    img.Target.Digest,
66
+						"platform": platform,
67 67
 					}).Warning("failed to get platform-specific rootfs")
68 68
 				}
69 69
 				continue
... ...
@@ -22,7 +22,6 @@ import (
22 22
 	"github.com/opencontainers/image-spec/specs-go"
23 23
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
24 24
 	"github.com/pkg/errors"
25
-	"github.com/sirupsen/logrus"
26 25
 )
27 26
 
28 27
 func (i *ImageService) PerformWithBaseFS(ctx context.Context, c *container.Container, fn func(root string) error) error {
... ...
@@ -97,14 +96,14 @@ func (i *ImageService) ExportImage(ctx context.Context, names []string, outStrea
97 97
 			ref = reference.TagNameOnly(ref)
98 98
 			opts = append(opts, archive.WithManifest(target, ref.String()))
99 99
 
100
-			log.G(ctx).WithFields(logrus.Fields{
100
+			log.G(ctx).WithFields(log.Fields{
101 101
 				"target": target,
102 102
 				"name":   ref.String(),
103 103
 			}).Debug("export image")
104 104
 		} else {
105 105
 			opts = append(opts, archive.WithManifest(target))
106 106
 
107
-			log.G(ctx).WithFields(logrus.Fields{
107
+			log.G(ctx).WithFields(log.Fields{
108 108
 				"target": target,
109 109
 			}).Debug("export image without name")
110 110
 		}
... ...
@@ -177,7 +176,7 @@ func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outSt
177 177
 		}
178 178
 
179 179
 		err = i.walkImageManifests(ctx, img, func(platformImg *ImageManifest) error {
180
-			logger := log.G(ctx).WithFields(logrus.Fields{
180
+			logger := log.G(ctx).WithFields(log.Fields{
181 181
 				"image":    name,
182 182
 				"manifest": platformImg.Target().Digest,
183 183
 			})
... ...
@@ -259,7 +258,7 @@ func (i *ImageService) getBestDescriptorForExport(ctx context.Context, indexDesc
259 259
 				log.G(ctx).WithField("manifest", mfst.Digest).Debug("manifest content present, will export")
260 260
 			} else {
261 261
 				hasMissingManifests = true
262
-				log.G(ctx).WithFields(logrus.Fields{
262
+				log.G(ctx).WithFields(log.Fields{
263 263
 					"manifest": mfst.Digest,
264 264
 					"missing":  missing,
265 265
 				}).Debug("manifest is missing, won't export")
... ...
@@ -26,7 +26,6 @@ import (
26 26
 	"github.com/opencontainers/image-spec/specs-go"
27 27
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
28 28
 	"github.com/pkg/errors"
29
-	"github.com/sirupsen/logrus"
30 29
 )
31 30
 
32 31
 // ImportImage imports an image, getting the archived layer data from layerReader.
... ...
@@ -67,7 +66,7 @@ func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, pla
67 67
 		logger.WithError(err).Debug("failed to write layer blob")
68 68
 		return "", err
69 69
 	}
70
-	logger = logger.WithFields(logrus.Fields{
70
+	logger = logger.WithFields(log.Fields{
71 71
 		"compressedDigest":   compressedDigest,
72 72
 		"uncompressedDigest": uncompressedDigest,
73 73
 	})
... ...
@@ -23,7 +23,6 @@ import (
23 23
 	"github.com/opencontainers/image-spec/identity"
24 24
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
25 25
 	"github.com/pkg/errors"
26
-	"github.com/sirupsen/logrus"
27 26
 )
28 27
 
29 28
 // Subset of ocispec.Image that only contains Labels
... ...
@@ -127,10 +126,10 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions)
127 127
 
128 128
 			available, err := img.CheckContentAvailable(ctx)
129 129
 			if err != nil {
130
-				log.G(ctx).WithFields(logrus.Fields{
131
-					logrus.ErrorKey: err,
132
-					"manifest":      img.Target(),
133
-					"image":         img.Name(),
130
+				log.G(ctx).WithFields(log.Fields{
131
+					"error":    err,
132
+					"manifest": img.Target(),
133
+					"image":    img.Name(),
134 134
 				}).Warn("checking availability of platform specific manifest failed")
135 135
 				return nil
136 136
 			}
... ...
@@ -189,7 +188,7 @@ func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore con
189 189
 	unpackedUsage, err := calculateSnapshotTotalUsage(ctx, snapshotter, imageSnapshotID)
190 190
 	if err != nil {
191 191
 		if !cerrdefs.IsNotFound(err) {
192
-			log.G(ctx).WithError(err).WithFields(logrus.Fields{
192
+			log.G(ctx).WithError(err).WithFields(log.Fields{
193 193
 				"image":      image.Name(),
194 194
 				"snapshotID": imageSnapshotID,
195 195
 			}).Warn("failed to calculate unpacked size of image")
... ...
@@ -210,7 +209,7 @@ func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore con
210 210
 	rawImg := image.Metadata()
211 211
 	target := rawImg.Target.Digest
212 212
 
213
-	logger := log.G(ctx).WithFields(logrus.Fields{
213
+	logger := log.G(ctx).WithFields(log.Fields{
214 214
 		"name":   rawImg.Name,
215 215
 		"digest": target,
216 216
 	})
... ...
@@ -469,10 +468,10 @@ func setupLabelFilter(store content.Store, fltrs filters.Args) (func(image image
469 469
 			return true
470 470
 		}
471 471
 		if err != nil {
472
-			log.G(ctx).WithFields(logrus.Fields{
473
-				logrus.ErrorKey: err,
474
-				"image":         image.Name,
475
-				"checks":        checks,
472
+			log.G(ctx).WithFields(log.Fields{
473
+				"error":  err,
474
+				"image":  image.Name,
475
+				"checks": checks,
476 476
 			}).Error("failed to check image labels")
477 477
 		}
478 478
 
... ...
@@ -15,7 +15,6 @@ import (
15 15
 	"github.com/opencontainers/go-digest"
16 16
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
17 17
 	"github.com/pkg/errors"
18
-	"github.com/sirupsen/logrus"
19 18
 )
20 19
 
21 20
 var imagesAcceptedFilters = map[string]bool{
... ...
@@ -80,7 +79,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
80 80
 
81 81
 		if !danglingOnly || isDanglingImage(img) {
82 82
 			canBePruned := filterFunc(img)
83
-			log.G(ctx).WithFields(logrus.Fields{
83
+			log.G(ctx).WithFields(log.Fields{
84 84
 				"image":       img.Name,
85 85
 				"canBePruned": canBePruned,
86 86
 			}).Debug("considering image for pruning")
... ...
@@ -116,7 +115,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
116 116
 		}
117 117
 
118 118
 		ref, err := reference.ParseNormalizedNamed(ctr.Config.Image)
119
-		log.G(ctx).WithFields(logrus.Fields{
119
+		log.G(ctx).WithFields(log.Fields{
120 120
 			"ctr":          ctr.ID,
121 121
 			"image":        ref,
122 122
 			"nameParseErr": err,
... ...
@@ -16,7 +16,6 @@ import (
16 16
 	"github.com/docker/docker/pkg/streamformatter"
17 17
 	"github.com/opencontainers/go-digest"
18 18
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
19
-	"github.com/sirupsen/logrus"
20 19
 )
21 20
 
22 21
 // PullImage initiates a pull operation. image is the repository name to pull, and
... ...
@@ -76,7 +75,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string,
76 76
 		return err
77 77
 	}
78 78
 
79
-	logger := log.G(ctx).WithFields(logrus.Fields{
79
+	logger := log.G(ctx).WithFields(log.Fields{
80 80
 		"digest": img.Target().Digest,
81 81
 		"remote": ref.String(),
82 82
 	})
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"github.com/docker/docker/errdefs"
11 11
 	"github.com/docker/docker/image"
12 12
 	"github.com/pkg/errors"
13
-	"github.com/sirupsen/logrus"
14 13
 )
15 14
 
16 15
 // TagImage creates an image named as newTag and targeting the given descriptor id.
... ...
@@ -55,7 +54,7 @@ func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag re
55 55
 		}
56 56
 	}
57 57
 
58
-	logger := log.G(ctx).WithFields(logrus.Fields{
58
+	logger := log.G(ctx).WithFields(log.Fields{
59 59
 		"imageID": imageID.String(),
60 60
 		"tag":     newTag.String(),
61 61
 	})
... ...
@@ -14,7 +14,6 @@ import (
14 14
 	"github.com/docker/docker/dockerversion"
15 15
 	"github.com/docker/docker/pkg/useragent"
16 16
 	"github.com/docker/docker/registry"
17
-	"github.com/sirupsen/logrus"
18 17
 )
19 18
 
20 19
 func (i *ImageService) newResolverFromAuthConfig(ctx context.Context, authConfig *registrytypes.AuthConfig) (remotes.Resolver, docker.StatusTracker) {
... ...
@@ -64,7 +63,7 @@ func authorizationCredsFromAuthConfig(authConfig registrytypes.AuthConfig) docke
64 64
 
65 65
 	return docker.WithAuthCreds(func(host string) (string, string, error) {
66 66
 		if cfgHost != host {
67
-			log.G(context.TODO()).WithFields(logrus.Fields{
67
+			log.G(context.TODO()).WithFields(log.Fields{
68 68
 				"host":    host,
69 69
 				"cfgHost": cfgHost,
70 70
 			}).Warn("Host doesn't match")
... ...
@@ -22,7 +22,6 @@ import (
22 22
 	"github.com/docker/docker/registry"
23 23
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
24 24
 	"github.com/pkg/errors"
25
-	"github.com/sirupsen/logrus"
26 25
 )
27 26
 
28 27
 // ImageService implements daemon.ImageService
... ...
@@ -175,7 +174,7 @@ func (i *ImageService) GetContainerLayerSize(ctx context.Context, containerID st
175 175
 			log.G(ctx).WithError(err).WithField("ctr", containerID).Warn("unexpected error when calculating usage of the parent snapshots")
176 176
 		}
177 177
 	}
178
-	log.G(ctx).WithFields(logrus.Fields{
178
+	log.G(ctx).WithFields(log.Fields{
179 179
 		"rwLayerUsage": rwLayerUsage.Size,
180 180
 		"unpacked":     unpackedUsage.Size,
181 181
 	}).Debug("GetContainerLayerSize")
... ...
@@ -192,7 +192,7 @@ func (daemon *Daemon) UsesSnapshotter() bool {
192 192
 // RegistryHosts returns the registry hosts configuration for the host component
193 193
 // of a distribution image reference.
194 194
 func (daemon *Daemon) RegistryHosts(host string) ([]docker.RegistryHost, error) {
195
-	var m = map[string]resolverconfig.RegistryConfig{}
195
+	m := map[string]resolverconfig.RegistryConfig{}
196 196
 
197 197
 	mirrors := daemon.registryService.ServiceConfig().Mirrors
198 198
 	m["docker.io"] = resolverconfig.RegistryConfig{Mirrors: mirrors}
... ...
@@ -268,27 +268,27 @@ func (daemon *Daemon) restore(cfg *configStore) error {
268 268
 			_ = sem.Acquire(context.Background(), 1)
269 269
 			defer sem.Release(1)
270 270
 
271
-			log := log.G(context.TODO()).WithField("container", id)
271
+			logger := log.G(context.TODO()).WithField("container", id)
272 272
 
273 273
 			c, err := daemon.load(id)
274 274
 			if err != nil {
275
-				log.WithError(err).Error("failed to load container")
275
+				logger.WithError(err).Error("failed to load container")
276 276
 				return
277 277
 			}
278 278
 			if c.Driver != daemon.imageService.StorageDriver() {
279 279
 				// Ignore the container if it wasn't created with the current storage-driver
280
-				log.Debugf("not restoring container because it was created with another storage driver (%s)", c.Driver)
280
+				logger.Debugf("not restoring container because it was created with another storage driver (%s)", c.Driver)
281 281
 				return
282 282
 			}
283 283
 			if accessor, ok := daemon.imageService.(layerAccessor); ok {
284 284
 				rwlayer, err := accessor.GetLayerByID(c.ID)
285 285
 				if err != nil {
286
-					log.WithError(err).Error("failed to load container mount")
286
+					logger.WithError(err).Error("failed to load container mount")
287 287
 					return
288 288
 				}
289 289
 				c.RWLayer = rwlayer
290 290
 			}
291
-			log.WithFields(logrus.Fields{
291
+			logger.WithFields(log.Fields{
292 292
 				"running": c.IsRunning(),
293 293
 				"paused":  c.IsPaused(),
294 294
 			}).Debug("loaded container")
... ...
@@ -311,17 +311,17 @@ func (daemon *Daemon) restore(cfg *configStore) error {
311 311
 			_ = sem.Acquire(context.Background(), 1)
312 312
 			defer sem.Release(1)
313 313
 
314
-			log := log.G(context.TODO()).WithField("container", c.ID)
314
+			logger := log.G(context.TODO()).WithField("container", c.ID)
315 315
 
316 316
 			if err := daemon.registerName(c); err != nil {
317
-				log.WithError(err).Errorf("failed to register container name: %s", c.Name)
317
+				logger.WithError(err).Errorf("failed to register container name: %s", c.Name)
318 318
 				mapLock.Lock()
319 319
 				delete(containers, c.ID)
320 320
 				mapLock.Unlock()
321 321
 				return
322 322
 			}
323 323
 			if err := daemon.Register(c); err != nil {
324
-				log.WithError(err).Error("failed to register container")
324
+				logger.WithError(err).Error("failed to register container")
325 325
 				mapLock.Lock()
326 326
 				delete(containers, c.ID)
327 327
 				mapLock.Unlock()
... ...
@@ -338,16 +338,16 @@ func (daemon *Daemon) restore(cfg *configStore) error {
338 338
 			_ = sem.Acquire(context.Background(), 1)
339 339
 			defer sem.Release(1)
340 340
 
341
-			log := log.G(context.TODO()).WithField("container", c.ID)
341
+			baseLogger := log.G(context.TODO()).WithField("container", c.ID)
342 342
 
343 343
 			if err := daemon.checkpointAndSave(c); err != nil {
344
-				log.WithError(err).Error("error saving backported mountspec to disk")
344
+				baseLogger.WithError(err).Error("error saving backported mountspec to disk")
345 345
 			}
346 346
 
347 347
 			daemon.setStateCounter(c)
348 348
 
349 349
 			logger := func(c *container.Container) *logrus.Entry {
350
-				return log.WithFields(logrus.Fields{
350
+				return baseLogger.WithFields(log.Fields{
351 351
 					"running":    c.IsRunning(),
352 352
 					"paused":     c.IsPaused(),
353 353
 					"restarting": c.IsRestarting(),
... ...
@@ -382,7 +382,7 @@ func (daemon *Daemon) restore(cfg *configStore) error {
382 382
 					} else if !cfg.LiveRestoreEnabled {
383 383
 						logger(c).Debug("shutting down container considered alive by containerd")
384 384
 						if err := daemon.shutdownContainer(c); err != nil && !errdefs.IsNotFound(err) {
385
-							log.WithError(err).Error("error shutting down container")
385
+							baseLogger.WithError(err).Error("error shutting down container")
386 386
 							return
387 387
 						}
388 388
 						status = containerd.Stopped
... ...
@@ -406,7 +406,7 @@ func (daemon *Daemon) restore(cfg *configStore) error {
406 406
 					case containerd.Paused, containerd.Pausing:
407 407
 						// nothing to do
408 408
 					case containerd.Unknown, containerd.Stopped, "":
409
-						log.WithField("status", status).Error("unexpected status for paused container during restore")
409
+						baseLogger.WithField("status", status).Error("unexpected status for paused container during restore")
410 410
 					default:
411 411
 						// running
412 412
 						c.Lock()
... ...
@@ -414,7 +414,7 @@ func (daemon *Daemon) restore(cfg *configStore) error {
414 414
 						daemon.setStateCounter(c)
415 415
 						daemon.updateHealthMonitor(c)
416 416
 						if err := c.CheckpointTo(daemon.containersReplica); err != nil {
417
-							log.WithError(err).Error("failed to update paused container state")
417
+							baseLogger.WithError(err).Error("failed to update paused container state")
418 418
 						}
419 419
 						c.Unlock()
420 420
 					}
... ...
@@ -438,7 +438,7 @@ func (daemon *Daemon) restore(cfg *configStore) error {
438 438
 					c.SetStopped(&ces)
439 439
 					daemon.Cleanup(c)
440 440
 					if err := c.CheckpointTo(daemon.containersReplica); err != nil {
441
-						log.WithError(err).Error("failed to update stopped container state")
441
+						baseLogger.WithError(err).Error("failed to update stopped container state")
442 442
 					}
443 443
 					c.Unlock()
444 444
 					logger(c).Debug("set stopped state")
... ...
@@ -502,9 +502,9 @@ func (daemon *Daemon) restore(cfg *configStore) error {
502 502
 				c.RemovalInProgress = false
503 503
 				c.Dead = true
504 504
 				if err := c.CheckpointTo(daemon.containersReplica); err != nil {
505
-					log.WithError(err).Error("failed to update RemovalInProgress container state")
505
+					baseLogger.WithError(err).Error("failed to update RemovalInProgress container state")
506 506
 				} else {
507
-					log.Debugf("reset RemovalInProgress state for container")
507
+					baseLogger.Debugf("reset RemovalInProgress state for container")
508 508
 				}
509 509
 			}
510 510
 			c.Unlock()
... ...
@@ -1170,7 +1170,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
1170 1170
 	engineCpus.Set(float64(info.NCPU))
1171 1171
 	engineMemory.Set(float64(info.MemTotal))
1172 1172
 
1173
-	log.G(ctx).WithFields(logrus.Fields{
1173
+	log.G(ctx).WithFields(log.Fields{
1174 1174
 		"version":     dockerversion.Version,
1175 1175
 		"commit":      dockerversion.GitCommit,
1176 1176
 		"graphdriver": d.ImageService().StorageDriver(),
... ...
@@ -1256,16 +1256,16 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error {
1256 1256
 			if !c.IsRunning() {
1257 1257
 				return
1258 1258
 			}
1259
-			log := log.G(ctx).WithField("container", c.ID)
1260
-			log.Debug("shutting down container")
1259
+			logger := log.G(ctx).WithField("container", c.ID)
1260
+			logger.Debug("shutting down container")
1261 1261
 			if err := daemon.shutdownContainer(c); err != nil {
1262
-				log.WithError(err).Error("failed to shut down container")
1262
+				logger.WithError(err).Error("failed to shut down container")
1263 1263
 				return
1264 1264
 			}
1265 1265
 			if mountid, err := daemon.imageService.GetLayerMountID(c.ID); err == nil {
1266 1266
 				daemon.cleanupMountsByID(mountid)
1267 1267
 			}
1268
-			log.Debugf("shut down container")
1268
+			logger.Debugf("shut down container")
1269 1269
 		})
1270 1270
 	}
1271 1271
 
... ...
@@ -14,7 +14,6 @@ import (
14 14
 	"github.com/docker/docker/layer"
15 15
 	"github.com/opencontainers/go-digest"
16 16
 	"github.com/pkg/errors"
17
-	"github.com/sirupsen/logrus"
18 17
 )
19 18
 
20 19
 const imageKeyPrefix = "moby-image-"
... ...
@@ -83,7 +82,7 @@ func (s *imageStoreForPull) updateLease(ctx context.Context, dgst digest.Digest)
83 83
 		Type: "content",
84 84
 	}
85 85
 	for _, dgst := range digested {
86
-		log.G(ctx).WithFields(logrus.Fields{
86
+		log.G(ctx).WithFields(log.Fields{
87 87
 			"digest": dgst,
88 88
 			"lease":  lease.ID,
89 89
 		}).Debug("Adding content digest to lease")
... ...
@@ -16,7 +16,6 @@ import (
16 16
 	"github.com/docker/docker/image"
17 17
 	"github.com/docker/go-connections/nat"
18 18
 	"github.com/pkg/errors"
19
-	"github.com/sirupsen/logrus"
20 19
 )
21 20
 
22 21
 var acceptedPsFilterTags = map[string]bool{
... ...
@@ -619,17 +618,16 @@ func (daemon *Daemon) refreshImage(ctx context.Context, s *container.Snapshot) (
619 619
 
620 620
 	// Check if the image reference still resolves to the same digest.
621 621
 	img, err := daemon.imageService.GetImage(ctx, s.Image, imagetypes.GetImageOpts{})
622
-
623 622
 	// If the image is no longer found or can't be resolved for some other
624 623
 	// reason. Update the Image to the specific ID of the original image it
625 624
 	// resolved to when the container was created.
626 625
 	if err != nil {
627 626
 		if !errdefs.IsNotFound(err) {
628
-			log.G(ctx).WithFields(logrus.Fields{
629
-				logrus.ErrorKey: err,
630
-				"containerID":   c.ID,
631
-				"image":         s.Image,
632
-				"imageID":       s.ImageID,
627
+			log.G(ctx).WithFields(log.Fields{
628
+				"error":       err,
629
+				"containerID": c.ID,
630
+				"image":       s.Image,
631
+				"imageID":     s.ImageID,
633 632
 			}).Warn("failed to resolve container image")
634 633
 		}
635 634
 		c.Image = s.ImageID
... ...
@@ -27,7 +27,6 @@ import (
27 27
 	"github.com/docker/docker/daemon/logger/loggerutils"
28 28
 	"github.com/docker/docker/dockerversion"
29 29
 	"github.com/pkg/errors"
30
-	"github.com/sirupsen/logrus"
31 30
 )
32 31
 
33 32
 const (
... ...
@@ -378,7 +377,7 @@ func newAWSLogsClient(info logger.Info, configOpts ...func(*config.LoadOptions)
378 378
 		return nil, errors.Wrap(err, "could not initialize AWS SDK config")
379 379
 	}
380 380
 
381
-	log.G(ctx).WithFields(logrus.Fields{
381
+	log.G(ctx).WithFields(log.Fields{
382 382
 		"region": *region,
383 383
 	}).Debug("Created awslogs client")
384 384
 
... ...
@@ -477,7 +476,7 @@ func (l *logStream) createLogGroup() error {
477 477
 	}); err != nil {
478 478
 		var apiErr smithy.APIError
479 479
 		if errors.As(err, &apiErr) {
480
-			fields := logrus.Fields{
480
+			fields := log.Fields{
481 481
 				"errorCode":      apiErr.ErrorCode(),
482 482
 				"message":        apiErr.ErrorMessage(),
483 483
 				"logGroupName":   l.logGroupName,
... ...
@@ -499,7 +498,7 @@ func (l *logStream) createLogGroup() error {
499 499
 func (l *logStream) createLogStream() error {
500 500
 	// Directly return if we do not want to create log stream.
501 501
 	if !l.logCreateStream {
502
-		log.G(context.TODO()).WithFields(logrus.Fields{
502
+		log.G(context.TODO()).WithFields(log.Fields{
503 503
 			"logGroupName":    l.logGroupName,
504 504
 			"logStreamName":   l.logStreamName,
505 505
 			"logCreateStream": l.logCreateStream,
... ...
@@ -516,7 +515,7 @@ func (l *logStream) createLogStream() error {
516 516
 	if err != nil {
517 517
 		var apiErr smithy.APIError
518 518
 		if errors.As(err, &apiErr) {
519
-			fields := logrus.Fields{
519
+			fields := log.Fields{
520 520
 				"errorCode":     apiErr.ErrorCode(),
521 521
 				"message":       apiErr.ErrorMessage(),
522 522
 				"logGroupName":  l.logGroupName,
... ...
@@ -695,7 +694,7 @@ func (l *logStream) publishBatch(batch *eventBatch) {
695 695
 		if apiErr := (*types.DataAlreadyAcceptedException)(nil); errors.As(err, &apiErr) {
696 696
 			// already submitted, just grab the correct sequence token
697 697
 			nextSequenceToken = apiErr.ExpectedSequenceToken
698
-			log.G(context.TODO()).WithFields(logrus.Fields{
698
+			log.G(context.TODO()).WithFields(log.Fields{
699 699
 				"errorCode":     apiErr.ErrorCode(),
700 700
 				"message":       apiErr.ErrorMessage(),
701 701
 				"logGroupName":  l.logGroupName,
... ...
@@ -725,7 +724,7 @@ func (l *logStream) putLogEvents(events []types.InputLogEvent, sequenceToken *st
725 725
 	if err != nil {
726 726
 		var apiErr smithy.APIError
727 727
 		if errors.As(err, &apiErr) {
728
-			log.G(context.TODO()).WithFields(logrus.Fields{
728
+			log.G(context.TODO()).WithFields(log.Fields{
729 729
 				"errorCode":     apiErr.ErrorCode(),
730 730
 				"message":       apiErr.ErrorMessage(),
731 731
 				"logGroupName":  l.logGroupName,
... ...
@@ -24,7 +24,7 @@ type follow struct {
24 24
 
25 25
 // Do follows the log file as it is written, starting from f at read.
26 26
 func (fl *follow) Do(f *os.File, read logPos) {
27
-	fl.log = log.G(context.TODO()).WithFields(logrus.Fields{
27
+	fl.log = log.G(context.TODO()).WithFields(log.Fields{
28 28
 		"module": "logger",
29 29
 		"file":   f.Name(),
30 30
 	})
... ...
@@ -16,7 +16,6 @@ import (
16 16
 	logcache "github.com/docker/docker/daemon/logger/loggerutils/cache"
17 17
 	"github.com/docker/docker/errdefs"
18 18
 	"github.com/pkg/errors"
19
-	"github.com/sirupsen/logrus"
20 19
 )
21 20
 
22 21
 // ContainerLogs copies the container's log channel to the channel provided in
... ...
@@ -26,7 +25,7 @@ import (
26 26
 // if it returns nil, the config channel will be active and return log
27 27
 // messages until it runs out or the context is canceled.
28 28
 func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *types.ContainerLogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
29
-	lg := log.G(ctx).WithFields(logrus.Fields{
29
+	lg := log.G(ctx).WithFields(log.Fields{
30 30
 		"module":    "daemon",
31 31
 		"method":    "(*Daemon).ContainerLogs",
32 32
 		"container": containerName,
... ...
@@ -13,7 +13,6 @@ import (
13 13
 	libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
14 14
 	"github.com/docker/docker/restartmanager"
15 15
 	"github.com/pkg/errors"
16
-	"github.com/sirupsen/logrus"
17 16
 )
18 17
 
19 18
 func (daemon *Daemon) setStateCounter(c *container.Container) {
... ...
@@ -43,9 +42,9 @@ func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontaine
43 43
 		es, err := tsk.Delete(ctx)
44 44
 		cancel()
45 45
 		if err != nil {
46
-			log.G(ctx).WithFields(logrus.Fields{
47
-				logrus.ErrorKey: err,
48
-				"container":     c.ID,
46
+			log.G(ctx).WithFields(log.Fields{
47
+				"error":     err,
48
+				"container": c.ID,
49 49
 			}).Warn("failed to delete container from containerd")
50 50
 		} else {
51 51
 			exitStatus = container.ExitStatus{
... ...
@@ -73,8 +72,8 @@ func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontaine
73 73
 	execDuration := time.Since(c.StartedAt)
74 74
 	restart, wait, err := c.RestartManager().ShouldRestart(uint32(exitStatus.ExitCode), daemonShutdown || c.HasBeenManuallyStopped, execDuration)
75 75
 	if err != nil {
76
-		log.G(ctx).WithFields(logrus.Fields{
77
-			logrus.ErrorKey:          err,
76
+		log.G(ctx).WithFields(log.Fields{
77
+			"error":                  err,
78 78
 			"container":              c.ID,
79 79
 			"restartCount":           c.RestartCount,
80 80
 			"exitStatus":             exitStatus,
... ...
@@ -93,7 +92,7 @@ func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontaine
93 93
 
94 94
 	if restart {
95 95
 		c.RestartCount++
96
-		log.G(ctx).WithFields(logrus.Fields{
96
+		log.G(ctx).WithFields(log.Fields{
97 97
 			"container":     c.ID,
98 98
 			"restartCount":  c.RestartCount,
99 99
 			"exitStatus":    exitStatus,
... ...
@@ -207,10 +206,10 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
207 207
 			if execConfig.Process != nil {
208 208
 				go func() {
209 209
 					if _, err := execConfig.Process.Delete(context.Background()); err != nil {
210
-						log.G(ctx).WithFields(logrus.Fields{
211
-							logrus.ErrorKey: err,
212
-							"container":     ei.ContainerID,
213
-							"process":       ei.ProcessID,
210
+						log.G(ctx).WithFields(log.Fields{
211
+							"error":     err,
212
+							"container": ei.ContainerID,
213
+							"process":   ei.ProcessID,
214 214
 						}).Warn("failed to delete process")
215 215
 					}
216 216
 				}()
... ...
@@ -232,9 +231,9 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
232 232
 				if errdefs.IsNotFound(err) {
233 233
 					// The container was started by not-docker and so could have been deleted by
234 234
 					// not-docker before we got around to loading it from containerd.
235
-					log.G(context.TODO()).WithFields(logrus.Fields{
236
-						logrus.ErrorKey: err,
237
-						"container":     c.ID,
235
+					log.G(context.TODO()).WithFields(log.Fields{
236
+						"error":     err,
237
+						"container": c.ID,
238 238
 					}).Debug("could not load containerd container for start event")
239 239
 					return nil
240 240
 				}
... ...
@@ -243,9 +242,9 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
243 243
 			tsk, err := ctr.Task(context.Background())
244 244
 			if err != nil {
245 245
 				if errdefs.IsNotFound(err) {
246
-					log.G(context.TODO()).WithFields(logrus.Fields{
247
-						logrus.ErrorKey: err,
248
-						"container":     c.ID,
246
+					log.G(context.TODO()).WithFields(log.Fields{
247
+						"error":     err,
248
+						"container": c.ID,
249 249
 					}).Debug("failed to load task for externally-started container")
250 250
 					return nil
251 251
 				}
... ...
@@ -311,5 +310,5 @@ func (daemon *Daemon) autoRemove(cfg *config.Config, c *container.Container) {
311 311
 		return
312 312
 	}
313 313
 
314
-	log.G(context.TODO()).WithFields(logrus.Fields{logrus.ErrorKey: err, "container": c.ID}).Error("error removing container")
314
+	log.G(context.TODO()).WithFields(log.Fields{"error": err, "container": c.ID}).Error("error removing container")
315 315
 }
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	mounttypes "github.com/docker/docker/api/types/mount"
10 10
 	"github.com/docker/docker/container"
11 11
 	volumesservice "github.com/docker/docker/volume/service"
12
-	"github.com/sirupsen/logrus"
13 12
 )
14 13
 
15 14
 func (daemon *Daemon) prepareMountPoints(container *container.Container) error {
... ...
@@ -23,7 +22,7 @@ func (daemon *Daemon) prepareMountPoints(container *container.Container) error {
23 23
 			continue
24 24
 		}
25 25
 		if alive {
26
-			log.G(context.TODO()).WithFields(logrus.Fields{
26
+			log.G(context.TODO()).WithFields(log.Fields{
27 27
 				"container": container.ID,
28 28
 				"volume":    config.Volume.Name(),
29 29
 			}).Debug("Live-restoring volume for alive container")
... ...
@@ -32,7 +32,6 @@ import (
32 32
 	"github.com/docker/docker/runconfig"
33 33
 	"github.com/docker/go-connections/nat"
34 34
 	"github.com/pkg/errors"
35
-	"github.com/sirupsen/logrus"
36 35
 )
37 36
 
38 37
 // PredefinedNetworkError is returned when user tries to create predefined network that already exists.
... ...
@@ -328,7 +327,7 @@ func (daemon *Daemon) createNetwork(cfg *config.Config, create types.NetworkCrea
328 328
 	if defaultOpts, ok := cfg.DefaultNetworkOpts[driver]; create.ConfigFrom == nil && ok {
329 329
 		for k, v := range defaultOpts {
330 330
 			if _, ok := networkOptions[k]; !ok {
331
-				log.G(context.TODO()).WithFields(logrus.Fields{"driver": driver, "network": id, k: v}).Debug("Applying network default option")
331
+				log.G(context.TODO()).WithFields(log.Fields{"driver": driver, "network": id, k: v}).Debug("Applying network default option")
332 332
 				networkOptions[k] = v
333 333
 			}
334 334
 		}
... ...
@@ -412,7 +411,7 @@ func (daemon *Daemon) pluginRefCount(driver, capability string, mode int) {
412 412
 	if daemon.PluginStore != nil {
413 413
 		_, err := daemon.PluginStore.Get(driver, capability, mode)
414 414
 		if err != nil {
415
-			log.G(context.TODO()).WithError(err).WithFields(logrus.Fields{"mode": mode, "driver": driver}).Error("Error handling plugin refcount operation")
415
+			log.G(context.TODO()).WithError(err).WithFields(log.Fields{"mode": mode, "driver": driver}).Error("Error handling plugin refcount operation")
416 416
 		}
417 417
 	}
418 418
 }
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"github.com/containerd/containerd/log"
10 10
 	"github.com/hashicorp/go-multierror"
11 11
 	"github.com/mitchellh/copystructure"
12
-	"github.com/sirupsen/logrus"
13 12
 
14 13
 	"github.com/docker/docker/daemon/config"
15 14
 )
... ...
@@ -280,7 +279,7 @@ func (daemon *Daemon) reloadNetworkDiagnosticPort(txn *reloadTxn, newCfg *config
280 280
 			return nil
281 281
 		}
282 282
 		// Enable the network diagnostic if the flag is set with a valid port within the range
283
-		log.G(context.TODO()).WithFields(logrus.Fields{"port": conf.NetworkDiagnosticPort, "ip": "127.0.0.1"}).Warn("Starting network diagnostic server")
283
+		log.G(context.TODO()).WithFields(log.Fields{"port": conf.NetworkDiagnosticPort, "ip": "127.0.0.1"}).Warn("Starting network diagnostic server")
284 284
 		daemon.netController.StartDiagnostic(conf.NetworkDiagnosticPort)
285 285
 		return nil
286 286
 	})
... ...
@@ -33,7 +33,6 @@ import (
33 33
 	"github.com/opencontainers/go-digest"
34 34
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
35 35
 	"github.com/pkg/errors"
36
-	"github.com/sirupsen/logrus"
37 36
 	archvariant "github.com/tonistiigi/go-archvariant"
38 37
 )
39 38
 
... ...
@@ -375,11 +374,10 @@ func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *oci
375 375
 		return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref))
376 376
 	}
377 377
 
378
-	ctx = log.WithLogger(ctx, log.G(ctx).WithFields(
379
-		logrus.Fields{
380
-			"digest": dgst,
381
-			"remote": ref,
382
-		}))
378
+	ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{
379
+		"digest": dgst,
380
+		"remote": ref,
381
+	}))
383 382
 
384 383
 	desc := ocispec.Descriptor{
385 384
 		MediaType: mt,
... ...
@@ -13,7 +13,6 @@ import (
13 13
 	"github.com/opencontainers/go-digest"
14 14
 	"github.com/opencontainers/go-digest/digestset"
15 15
 	"github.com/pkg/errors"
16
-	"github.com/sirupsen/logrus"
17 16
 )
18 17
 
19 18
 // Store is an interface for creating and accessing images
... ...
@@ -75,7 +74,7 @@ func (is *store) restore() error {
75 75
 	// if we don't need it. The "f" type alias is here is just for convenience,
76 76
 	// and to make the code _slightly_ more DRY. See the discussion on GitHub;
77 77
 	// https://github.com/moby/moby/pull/44426#discussion_r1059519071
78
-	type f = logrus.Fields
78
+	type f = log.Fields
79 79
 	err := is.fs.Walk(func(dgst digest.Digest) error {
80 80
 		img, err := is.Get(ID(dgst))
81 81
 		if err != nil {
... ...
@@ -9,8 +9,8 @@ import (
9 9
 	"testing"
10 10
 	"time"
11 11
 
12
+	"github.com/containerd/containerd/log"
12 13
 	"github.com/docker/docker/integration-cli/cli"
13
-	"github.com/docker/docker/pkg/jsonmessage"
14 14
 	"gotest.tools/v3/assert"
15 15
 	"gotest.tools/v3/icmd"
16 16
 )
... ...
@@ -67,7 +67,7 @@ func (s *DockerCLILogsSuite) TestLogsTimestamps(c *testing.T) {
67 67
 
68 68
 	for _, l := range lines {
69 69
 		if l != "" {
70
-			_, err := time.Parse(jsonmessage.RFC3339NanoFixed+" ", ts.FindString(l))
70
+			_, err := time.Parse(log.RFC3339NanoFixed+" ", ts.FindString(l))
71 71
 			assert.NilError(c, err, "Failed to parse timestamp from %v", l)
72 72
 			// ensure we have padded 0's
73 73
 			assert.Equal(c, l[29], uint8('Z'))
... ...
@@ -163,13 +163,13 @@ func (c *client) NewContainer(_ context.Context, id string, spec *specs.Spec, sh
163 163
 			ei := libcontainerdtypes.EventInfo{
164 164
 				ContainerID: id,
165 165
 			}
166
-			c.logger.WithFields(logrus.Fields{
166
+			c.logger.WithFields(log.Fields{
167 167
 				"container": id,
168 168
 				"event":     libcontainerdtypes.EventCreate,
169 169
 			}).Info("sending event")
170 170
 			err := c.backend.ProcessEvent(id, libcontainerdtypes.EventCreate, ei)
171 171
 			if err != nil {
172
-				c.logger.WithError(err).WithFields(logrus.Fields{
172
+				c.logger.WithError(err).WithFields(log.Fields{
173 173
 					"container": id,
174 174
 					"event":     libcontainerdtypes.EventCreate,
175 175
 				}).Error("failed to process event")
... ...
@@ -498,14 +498,14 @@ func (ctr *container) Start(_ context.Context, _ string, withStdin bool, attachS
498 498
 			ProcessID:   t.id,
499 499
 			Pid:         pid,
500 500
 		}
501
-		ctr.client.logger.WithFields(logrus.Fields{
501
+		ctr.client.logger.WithFields(log.Fields{
502 502
 			"container":  ctr.id,
503 503
 			"event":      libcontainerdtypes.EventStart,
504 504
 			"event-info": ei,
505 505
 		}).Info("sending event")
506 506
 		err := ctr.client.backend.ProcessEvent(ei.ContainerID, libcontainerdtypes.EventStart, ei)
507 507
 		if err != nil {
508
-			ctr.client.logger.WithError(err).WithFields(logrus.Fields{
508
+			ctr.client.logger.WithError(err).WithFields(log.Fields{
509 509
 				"container":  ei.ContainerID,
510 510
 				"event":      libcontainerdtypes.EventStart,
511 511
 				"event-info": ei,
... ...
@@ -562,7 +562,7 @@ func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process,
562 562
 	if err != nil {
563 563
 		return nil, err
564 564
 	}
565
-	logger := t.ctr.client.logger.WithFields(logrus.Fields{
565
+	logger := t.ctr.client.logger.WithFields(log.Fields{
566 566
 		"container": t.ctr.id,
567 567
 		"exec":      processID,
568 568
 	})
... ...
@@ -654,14 +654,14 @@ func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process,
654 654
 			ProcessID:   p.id,
655 655
 			Pid:         uint32(pid),
656 656
 		}
657
-		t.ctr.client.logger.WithFields(logrus.Fields{
657
+		t.ctr.client.logger.WithFields(log.Fields{
658 658
 			"container":  t.ctr.id,
659 659
 			"event":      libcontainerdtypes.EventExecAdded,
660 660
 			"event-info": ei,
661 661
 		}).Info("sending event")
662 662
 		err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventExecAdded, ei)
663 663
 		if err != nil {
664
-			t.ctr.client.logger.WithError(err).WithFields(logrus.Fields{
664
+			t.ctr.client.logger.WithError(err).WithFields(log.Fields{
665 665
 				"container":  t.ctr.id,
666 666
 				"event":      libcontainerdtypes.EventExecAdded,
667 667
 				"event-info": ei,
... ...
@@ -669,7 +669,7 @@ func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process,
669 669
 		}
670 670
 		err = t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventExecStarted, ei)
671 671
 		if err != nil {
672
-			t.ctr.client.logger.WithError(err).WithFields(logrus.Fields{
672
+			t.ctr.client.logger.WithError(err).WithFields(log.Fields{
673 673
 				"container":  t.ctr.id,
674 674
 				"event":      libcontainerdtypes.EventExecStarted,
675 675
 				"event-info": ei,
... ...
@@ -709,7 +709,7 @@ func (t *task) Kill(_ context.Context, signal syscall.Signal) error {
709 709
 		return err
710 710
 	}
711 711
 
712
-	logger := t.ctr.client.logger.WithFields(logrus.Fields{
712
+	logger := t.ctr.client.logger.WithFields(log.Fields{
713 713
 		"container": t.ctr.id,
714 714
 		"process":   t.id,
715 715
 		"pid":       t.Pid(),
... ...
@@ -748,7 +748,7 @@ func (p *process) Resize(_ context.Context, width, height uint32) error {
748 748
 		return errors.WithStack(errdefs.NotFound(errors.New("process not found")))
749 749
 	}
750 750
 
751
-	p.ctr.client.logger.WithFields(logrus.Fields{
751
+	p.ctr.client.logger.WithFields(log.Fields{
752 752
 		"container": p.ctr.id,
753 753
 		"process":   p.id,
754 754
 		"height":    height,
... ...
@@ -795,12 +795,12 @@ func (t *task) Pause(_ context.Context) error {
795 795
 			ContainerID: t.ctr.id,
796 796
 			ProcessID:   t.id,
797 797
 		})
798
-		t.ctr.client.logger.WithFields(logrus.Fields{
798
+		t.ctr.client.logger.WithFields(log.Fields{
799 799
 			"container": t.ctr.id,
800 800
 			"event":     libcontainerdtypes.EventPaused,
801 801
 		}).Info("sending event")
802 802
 		if err != nil {
803
-			t.ctr.client.logger.WithError(err).WithFields(logrus.Fields{
803
+			t.ctr.client.logger.WithError(err).WithFields(log.Fields{
804 804
 				"container": t.ctr.id,
805 805
 				"event":     libcontainerdtypes.EventPaused,
806 806
 			}).Error("failed to process event")
... ...
@@ -836,12 +836,12 @@ func (t *task) Resume(ctx context.Context) error {
836 836
 			ContainerID: t.ctr.id,
837 837
 			ProcessID:   t.id,
838 838
 		})
839
-		t.ctr.client.logger.WithFields(logrus.Fields{
839
+		t.ctr.client.logger.WithFields(log.Fields{
840 840
 			"container": t.ctr.id,
841 841
 			"event":     libcontainerdtypes.EventResumed,
842 842
 		}).Info("sending event")
843 843
 		if err != nil {
844
-			t.ctr.client.logger.WithError(err).WithFields(logrus.Fields{
844
+			t.ctr.client.logger.WithError(err).WithFields(log.Fields{
845 845
 				"container": t.ctr.id,
846 846
 				"event":     libcontainerdtypes.EventResumed,
847 847
 			}).Error("failed to process event")
... ...
@@ -1109,7 +1109,7 @@ func (ctr *container) terminateContainer() error {
1109 1109
 }
1110 1110
 
1111 1111
 func (p *process) reap() {
1112
-	logger := p.ctr.client.logger.WithFields(logrus.Fields{
1112
+	logger := p.ctr.client.logger.WithFields(log.Fields{
1113 1113
 		"container": p.ctr.id,
1114 1114
 		"process":   p.id,
1115 1115
 	})
... ...
@@ -1166,14 +1166,14 @@ func (p *process) reap() {
1166 1166
 			ExitedAt:    exitedAt,
1167 1167
 			Error:       eventErr,
1168 1168
 		}
1169
-		p.ctr.client.logger.WithFields(logrus.Fields{
1169
+		p.ctr.client.logger.WithFields(log.Fields{
1170 1170
 			"container":  p.ctr.id,
1171 1171
 			"event":      libcontainerdtypes.EventExit,
1172 1172
 			"event-info": ei,
1173 1173
 		}).Info("sending event")
1174 1174
 		err := p.ctr.client.backend.ProcessEvent(p.ctr.id, libcontainerdtypes.EventExit, ei)
1175 1175
 		if err != nil {
1176
-			p.ctr.client.logger.WithError(err).WithFields(logrus.Fields{
1176
+			p.ctr.client.logger.WithError(err).WithFields(log.Fields{
1177 1177
 				"container":  p.ctr.id,
1178 1178
 				"event":      libcontainerdtypes.EventExit,
1179 1179
 				"event-info": ei,
... ...
@@ -1200,7 +1200,7 @@ func (ctr *container) Delete(context.Context) error {
1200 1200
 	}
1201 1201
 
1202 1202
 	var (
1203
-		logger = ctr.client.logger.WithFields(logrus.Fields{
1203
+		logger = ctr.client.logger.WithFields(log.Fields{
1204 1204
 			"container": ctr.id,
1205 1205
 		})
1206 1206
 		thisErr error
... ...
@@ -167,7 +167,7 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b
167 167
 			if checkpoint != nil {
168 168
 				err := c.client.client.ContentStore().Delete(ctx, checkpoint.Digest)
169 169
 				if err != nil {
170
-					c.client.logger.WithError(err).WithFields(logrus.Fields{
170
+					c.client.logger.WithError(err).WithFields(log.Fields{
171 171
 						"ref":    checkpointDir,
172 172
 						"digest": checkpoint.Digest,
173 173
 					}).Warnf("failed to delete temporary checkpoint entry")
... ...
@@ -392,7 +392,7 @@ func (c *container) Delete(ctx context.Context) error {
392 392
 	}
393 393
 	if os.Getenv("LIBCONTAINERD_NOCLEAN") != "1" {
394 394
 		if err := os.RemoveAll(bundle); err != nil {
395
-			c.client.logger.WithContext(ctx).WithError(err).WithFields(logrus.Fields{
395
+			c.client.logger.WithContext(ctx).WithError(err).WithFields(log.Fields{
396 396
 				"container": c.c8dCtr.ID(),
397 397
 				"bundle":    bundle,
398 398
 			}).Error("failed to remove state dir")
... ...
@@ -573,7 +573,7 @@ func (c *client) processEvent(ctx context.Context, et libcontainerdtypes.EventTy
573 573
 	c.eventQ.Append(ei.ContainerID, func() {
574 574
 		err := c.backend.ProcessEvent(ei.ContainerID, et, ei)
575 575
 		if err != nil {
576
-			c.logger.WithContext(ctx).WithError(err).WithFields(logrus.Fields{
576
+			c.logger.WithContext(ctx).WithError(err).WithFields(log.Fields{
577 577
 				"container":  ei.ContainerID,
578 578
 				"event":      et,
579 579
 				"event-info": ei,
... ...
@@ -718,7 +718,7 @@ func (c *client) processEventStream(ctx context.Context, ns string) {
718 718
 					ContainerID: t.ContainerID,
719 719
 				}
720 720
 			case *apievents.TaskDelete:
721
-				c.logger.WithFields(logrus.Fields{
721
+				c.logger.WithFields(log.Fields{
722 722
 					"topic":     ev.Topic,
723 723
 					"type":      reflect.TypeOf(t),
724 724
 					"container": t.ContainerID,
... ...
@@ -726,7 +726,7 @@ func (c *client) processEventStream(ctx context.Context, ns string) {
726 726
 				).Info("ignoring event")
727 727
 				continue
728 728
 			default:
729
-				c.logger.WithFields(logrus.Fields{
729
+				c.logger.WithFields(log.Fields{
730 730
 					"topic": ev.Topic,
731 731
 					"type":  reflect.TypeOf(t),
732 732
 				},
... ...
@@ -7,8 +7,8 @@ import (
7 7
 
8 8
 	winio "github.com/Microsoft/go-winio"
9 9
 	"github.com/containerd/containerd/cio"
10
+	"github.com/containerd/containerd/log"
10 11
 	"github.com/pkg/errors"
11
-	"github.com/sirupsen/logrus"
12 12
 )
13 13
 
14 14
 type delayedConnection struct {
... ...
@@ -59,7 +59,7 @@ type stdioPipes struct {
59 59
 func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
60 60
 	p := &stdioPipes{}
61 61
 	if fifos.Stdin != "" {
62
-		c.logger.WithFields(logrus.Fields{"stdin": fifos.Stdin}).Debug("listen")
62
+		c.logger.WithField("stdin", fifos.Stdin).Debug("listen")
63 63
 		l, err := winio.ListenPipe(fifos.Stdin, nil)
64 64
 		if err != nil {
65 65
 			return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.Stdin)
... ...
@@ -76,7 +76,7 @@ func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
76 76
 		p.stdin = dc
77 77
 
78 78
 		go func() {
79
-			c.logger.WithFields(logrus.Fields{"stdin": fifos.Stdin}).Debug("accept")
79
+			c.logger.WithField("stdin", fifos.Stdin).Debug("accept")
80 80
 			conn, err := l.Accept()
81 81
 			if err != nil {
82 82
 				dc.Close()
... ...
@@ -85,14 +85,14 @@ func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
85 85
 				}
86 86
 				return
87 87
 			}
88
-			c.logger.WithFields(logrus.Fields{"stdin": fifos.Stdin}).Debug("connected")
88
+			c.logger.WithField("stdin", fifos.Stdin).Debug("connected")
89 89
 			dc.con = conn
90 90
 			dc.unblockConnectionWaiters()
91 91
 		}()
92 92
 	}
93 93
 
94 94
 	if fifos.Stdout != "" {
95
-		c.logger.WithFields(logrus.Fields{"stdout": fifos.Stdout}).Debug("listen")
95
+		c.logger.WithField("stdout", fifos.Stdout).Debug("listen")
96 96
 		l, err := winio.ListenPipe(fifos.Stdout, nil)
97 97
 		if err != nil {
98 98
 			return nil, errors.Wrapf(err, "failed to create stdout pipe %s", fifos.Stdout)
... ...
@@ -109,23 +109,23 @@ func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
109 109
 		p.stdout = dc
110 110
 
111 111
 		go func() {
112
-			c.logger.WithFields(logrus.Fields{"stdout": fifos.Stdout}).Debug("accept")
112
+			c.logger.WithField("stdout", fifos.Stdout).Debug("accept")
113 113
 			conn, err := l.Accept()
114 114
 			if err != nil {
115 115
 				dc.Close()
116 116
 				if err != winio.ErrPipeListenerClosed {
117
-					c.logger.WithError(err).Errorf("failed to accept stdout connection on %s", fifos.Stdout)
117
+					c.logger.WithFields(log.Fields{"error": err, "stdout": fifos.Stdout}).Error("failed to accept stdout connection")
118 118
 				}
119 119
 				return
120 120
 			}
121
-			c.logger.WithFields(logrus.Fields{"stdout": fifos.Stdout}).Debug("connected")
121
+			c.logger.WithField("stdout", fifos.Stdout).Debug("connected")
122 122
 			dc.con = conn
123 123
 			dc.unblockConnectionWaiters()
124 124
 		}()
125 125
 	}
126 126
 
127 127
 	if fifos.Stderr != "" {
128
-		c.logger.WithFields(logrus.Fields{"stderr": fifos.Stderr}).Debug("listen")
128
+		c.logger.WithField("stderr", fifos.Stderr).Debug("listen")
129 129
 		l, err := winio.ListenPipe(fifos.Stderr, nil)
130 130
 		if err != nil {
131 131
 			return nil, errors.Wrapf(err, "failed to create stderr pipe %s", fifos.Stderr)
... ...
@@ -142,7 +142,7 @@ func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
142 142
 		p.stderr = dc
143 143
 
144 144
 		go func() {
145
-			c.logger.WithFields(logrus.Fields{"stderr": fifos.Stderr}).Debug("accept")
145
+			c.logger.WithField("stderr", fifos.Stderr).Debug("accept")
146 146
 			conn, err := l.Accept()
147 147
 			if err != nil {
148 148
 				dc.Close()
... ...
@@ -151,7 +151,7 @@ func (c *client) newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, err error) {
151 151
 				}
152 152
 				return
153 153
 			}
154
-			c.logger.WithFields(logrus.Fields{"stderr": fifos.Stderr}).Debug("connected")
154
+			c.logger.WithField("stderr", fifos.Stderr).Debug("connected")
155 155
 			dc.con = conn
156 156
 			dc.unblockConnectionWaiters()
157 157
 		}()
... ...
@@ -12,8 +12,6 @@ import (
12 12
 	"os"
13 13
 	"strings"
14 14
 
15
-	"github.com/sirupsen/logrus"
16
-
17 15
 	"github.com/containerd/containerd/log"
18 16
 	"github.com/docker/docker/libnetwork"
19 17
 	"github.com/docker/docker/libnetwork/diagnostic"
... ...
@@ -53,7 +51,7 @@ func main() {
53 53
 	flag.Parse()
54 54
 
55 55
 	if *verbosePtr {
56
-		logrus.SetLevel(logrus.DebugLevel)
56
+		_ = log.SetLevel("debug")
57 57
 	}
58 58
 
59 59
 	if _, ok := os.LookupEnv("DIND_CLIENT"); !ok && *joinPtr {
... ...
@@ -4,18 +4,13 @@ import (
4 4
 	"context"
5 5
 	"os"
6 6
 
7
-	"github.com/sirupsen/logrus"
8
-
9 7
 	"github.com/containerd/containerd/log"
10 8
 	"github.com/docker/docker/libnetwork/cmd/networkdb-test/dbclient"
11 9
 	"github.com/docker/docker/libnetwork/cmd/networkdb-test/dbserver"
12 10
 )
13 11
 
14 12
 func main() {
15
-	formatter := &logrus.TextFormatter{
16
-		FullTimestamp: true,
17
-	}
18
-	logrus.SetFormatter(formatter)
13
+	_ = log.SetFormat(log.TextFormat)
19 14
 	log.G(context.TODO()).Infof("Starting the image with these args: %v", os.Args)
20 15
 	if len(os.Args) < 1 {
21 16
 		log.G(context.TODO()).Fatal("You need at least 1 argument [client/server]")
... ...
@@ -14,7 +14,6 @@ import (
14 14
 	"github.com/containerd/containerd/log"
15 15
 	"github.com/docker/docker/libnetwork/internal/caller"
16 16
 	"github.com/docker/docker/pkg/stack"
17
-	"github.com/sirupsen/logrus"
18 17
 )
19 18
 
20 19
 // HTTPHandlerFunc TODO
... ...
@@ -130,24 +129,32 @@ func (s *Server) IsDiagnosticEnabled() bool {
130 130
 }
131 131
 
132 132
 func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) {
133
-	r.ParseForm() //nolint:errcheck
134
-	_, json := ParseHTTPFormOptions(r)
133
+	_ = r.ParseForm()
134
+	_, jsonOutput := ParseHTTPFormOptions(r)
135 135
 	rsp := WrongCommand("not implemented", fmt.Sprintf("URL path: %s no method implemented check /help\n", r.URL.Path))
136 136
 
137 137
 	// audit logs
138
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
139
-	log.Info("command not implemented done")
138
+	log.G(context.TODO()).WithFields(log.Fields{
139
+		"component": "diagnostic",
140
+		"remoteIP":  r.RemoteAddr,
141
+		"method":    caller.Name(0),
142
+		"url":       r.URL.String(),
143
+	}).Info("command not implemented done")
140 144
 
141
-	HTTPReply(w, rsp, json) //nolint:errcheck
145
+	_, _ = HTTPReply(w, rsp, jsonOutput)
142 146
 }
143 147
 
144 148
 func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
145
-	r.ParseForm() //nolint:errcheck
146
-	_, json := ParseHTTPFormOptions(r)
149
+	_ = r.ParseForm()
150
+	_, jsonOutput := ParseHTTPFormOptions(r)
147 151
 
148 152
 	// audit logs
149
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
150
-	log.Info("help done")
153
+	log.G(context.TODO()).WithFields(log.Fields{
154
+		"component": "diagnostic",
155
+		"remoteIP":  r.RemoteAddr,
156
+		"method":    caller.Name(0),
157
+		"url":       r.URL.String(),
158
+	}).Info("help done")
151 159
 
152 160
 	n, ok := ctx.(*Server)
153 161
 	var result string
... ...
@@ -155,35 +162,39 @@ func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
155 155
 		for path := range n.registeredHanders {
156 156
 			result += fmt.Sprintf("%s\n", path)
157 157
 		}
158
-		HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), json) //nolint:errcheck
158
+		_, _ = HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), jsonOutput)
159 159
 	}
160 160
 }
161 161
 
162 162
 func ready(ctx interface{}, w http.ResponseWriter, r *http.Request) {
163
-	r.ParseForm() //nolint:errcheck
164
-	_, json := ParseHTTPFormOptions(r)
163
+	_ = r.ParseForm()
164
+	_, jsonOutput := ParseHTTPFormOptions(r)
165 165
 
166 166
 	// audit logs
167
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
168
-	log.Info("ready done")
169
-	HTTPReply(w, CommandSucceed(&StringCmd{Info: "OK"}), json) //nolint:errcheck
167
+	log.G(context.TODO()).WithFields(log.Fields{
168
+		"component": "diagnostic",
169
+		"remoteIP":  r.RemoteAddr,
170
+		"method":    caller.Name(0),
171
+		"url":       r.URL.String(),
172
+	}).Info("ready done")
173
+	_, _ = HTTPReply(w, CommandSucceed(&StringCmd{Info: "OK"}), jsonOutput)
170 174
 }
171 175
 
172 176
 func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
173
-	r.ParseForm() //nolint:errcheck
174
-	_, json := ParseHTTPFormOptions(r)
177
+	_ = r.ParseForm()
178
+	_, jsonOutput := ParseHTTPFormOptions(r)
175 179
 
176 180
 	// audit logs
177
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
178
-	log.Info("stack trace")
181
+	logger := log.G(context.TODO()).WithFields(log.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
182
+	logger.Info("stack trace")
179 183
 
180 184
 	path, err := stack.DumpToFile("/tmp/")
181 185
 	if err != nil {
182
-		log.WithError(err).Error("failed to write goroutines dump")
183
-		HTTPReply(w, FailCommand(err), json) //nolint:errcheck
186
+		logger.WithError(err).Error("failed to write goroutines dump")
187
+		_, _ = HTTPReply(w, FailCommand(err), jsonOutput)
184 188
 	} else {
185
-		log.Info("stack trace done")
186
-		HTTPReply(w, CommandSucceed(&StringCmd{Info: fmt.Sprintf("goroutine stacks written to %s", path)}), json) //nolint:errcheck
189
+		logger.Info("stack trace done")
190
+		_, _ = HTTPReply(w, CommandSucceed(&StringCmd{Info: "goroutine stacks written to " + path}), jsonOutput)
187 191
 	}
188 192
 }
189 193
 
... ...
@@ -203,12 +214,12 @@ type JSONOutput struct {
203 203
 // ParseHTTPFormOptions easily parse the JSON printing options
204 204
 func ParseHTTPFormOptions(r *http.Request) (bool, *JSONOutput) {
205 205
 	_, unsafe := r.Form["unsafe"]
206
-	v, json := r.Form["json"]
206
+	v, enableJSON := r.Form["json"]
207 207
 	var pretty bool
208 208
 	if len(v) > 0 {
209 209
 		pretty = v[0] == "pretty"
210 210
 	}
211
-	return unsafe, &JSONOutput{enable: json, prettyPrint: pretty}
211
+	return unsafe, &JSONOutput{enable: enableJSON, prettyPrint: pretty}
212 212
 }
213 213
 
214 214
 // HTTPReply helper function that takes care of sending the message out
... ...
@@ -22,7 +22,6 @@ import (
22 22
 	"github.com/docker/docker/libnetwork/osl"
23 23
 	"github.com/docker/docker/libnetwork/types"
24 24
 	"github.com/hashicorp/go-multierror"
25
-	"github.com/sirupsen/logrus"
26 25
 	"github.com/vishvananda/netlink"
27 26
 	"github.com/vishvananda/netns"
28 27
 	"golang.org/x/sys/unix"
... ...
@@ -217,17 +216,17 @@ func (d *driver) DeleteNetwork(nid string) error {
217 217
 	if n.secure {
218 218
 		for _, s := range n.subnets {
219 219
 			if err := programMangle(s.vni, false); err != nil {
220
-				log.G(context.TODO()).WithFields(logrus.Fields{
221
-					logrus.ErrorKey: err,
222
-					"network_id":    n.id,
223
-					"subnet":        s.subnetIP,
220
+				log.G(context.TODO()).WithFields(log.Fields{
221
+					"error":      err,
222
+					"network_id": n.id,
223
+					"subnet":     s.subnetIP,
224 224
 				}).Warn("Failed to clean up iptables rules during overlay network deletion")
225 225
 			}
226 226
 			if err := programInput(s.vni, false); err != nil {
227
-				log.G(context.TODO()).WithFields(logrus.Fields{
228
-					logrus.ErrorKey: err,
229
-					"network_id":    n.id,
230
-					"subnet":        s.subnetIP,
227
+				log.G(context.TODO()).WithFields(log.Fields{
228
+					"error":      err,
229
+					"network_id": n.id,
230
+					"subnet":     s.subnetIP,
231 231
 				}).Warn("Failed to clean up iptables rules during overlay network deletion")
232 232
 			}
233 233
 		}
... ...
@@ -14,7 +14,6 @@ import (
14 14
 	"github.com/docker/docker/pkg/stringid"
15 15
 	"github.com/docker/go-events"
16 16
 	"github.com/hashicorp/memberlist"
17
-	"github.com/sirupsen/logrus"
18 17
 	"gotest.tools/v3/assert"
19 18
 	is "gotest.tools/v3/assert/cmp"
20 19
 	"gotest.tools/v3/poll"
... ...
@@ -24,7 +23,7 @@ var dbPort int32 = 10000
24 24
 
25 25
 func TestMain(m *testing.M) {
26 26
 	os.WriteFile("/proc/sys/net/ipv6/conf/lo/disable_ipv6", []byte{'0', '\n'}, 0o644)
27
-	logrus.SetLevel(logrus.ErrorLevel)
27
+	log.SetLevel("error")
28 28
 	os.Exit(m.Run())
29 29
 }
30 30
 
... ...
@@ -840,7 +839,7 @@ func TestNetworkDBIslands(t *testing.T) {
840 840
 		return defaultTimeout
841 841
 	}
842 842
 
843
-	logrus.SetLevel(logrus.DebugLevel)
843
+	_ = log.SetLevel("debug")
844 844
 	conf := DefaultConfig()
845 845
 	// Shorten durations to speed up test execution.
846 846
 	conf.rejoinClusterDuration = conf.rejoinClusterDuration / 10
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"github.com/containerd/containerd/log"
11 11
 	"github.com/docker/docker/libnetwork/diagnostic"
12 12
 	"github.com/docker/docker/libnetwork/internal/caller"
13
-	"github.com/sirupsen/logrus"
14 13
 )
15 14
 
16 15
 const (
... ...
@@ -34,17 +33,22 @@ var NetDbPaths2Func = map[string]diagnostic.HTTPHandlerFunc{
34 34
 }
35 35
 
36 36
 func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) {
37
-	r.ParseForm()
37
+	_ = r.ParseForm()
38 38
 	diagnostic.DebugHTTPForm(r)
39 39
 	_, json := diagnostic.ParseHTTPFormOptions(r)
40 40
 
41 41
 	// audit logs
42
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
43
-	log.Info("join cluster")
42
+	logger := log.G(context.TODO()).WithFields(log.Fields{
43
+		"component": "diagnostic",
44
+		"remoteIP":  r.RemoteAddr,
45
+		"method":    caller.Name(0),
46
+		"url":       r.URL.String(),
47
+	})
48
+	logger.Info("join cluster")
44 49
 
45 50
 	if len(r.Form["members"]) < 1 {
46 51
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?members=ip1,ip2,...", r.URL.Path))
47
-		log.Error("join cluster failed, wrong input")
52
+		logger.Error("join cluster failed, wrong input")
48 53
 		diagnostic.HTTPReply(w, rsp, json)
49 54
 		return
50 55
 	}
... ...
@@ -54,12 +58,12 @@ func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) {
54 54
 		err := nDB.Join(strings.Split(r.Form["members"][0], ","))
55 55
 		if err != nil {
56 56
 			rsp := diagnostic.FailCommand(fmt.Errorf("%s error in the DB join %s", r.URL.Path, err))
57
-			log.WithError(err).Error("join cluster failed")
57
+			logger.WithError(err).Error("join cluster failed")
58 58
 			diagnostic.HTTPReply(w, rsp, json)
59 59
 			return
60 60
 		}
61 61
 
62
-		log.Info("join cluster done")
62
+		logger.Info("join cluster done")
63 63
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json)
64 64
 		return
65 65
 	}
... ...
@@ -67,17 +71,22 @@ func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) {
67 67
 }
68 68
 
69 69
 func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
70
-	r.ParseForm()
70
+	_ = r.ParseForm()
71 71
 	diagnostic.DebugHTTPForm(r)
72 72
 	_, json := diagnostic.ParseHTTPFormOptions(r)
73 73
 
74 74
 	// audit logs
75
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
76
-	log.Info("network peers")
75
+	logger := log.G(context.TODO()).WithFields(log.Fields{
76
+		"component": "diagnostic",
77
+		"remoteIP":  r.RemoteAddr,
78
+		"method":    caller.Name(0),
79
+		"url":       r.URL.String(),
80
+	})
81
+	logger.Info("network peers")
77 82
 
78 83
 	if len(r.Form["nid"]) < 1 {
79 84
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?nid=test", r.URL.Path))
80
-		log.Error("network peers failed, wrong input")
85
+		logger.Error("network peers failed, wrong input")
81 86
 		diagnostic.HTTPReply(w, rsp, json)
82 87
 		return
83 88
 	}
... ...
@@ -93,7 +102,7 @@ func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
93 93
 				rsp.Elements = append(rsp.Elements, &diagnostic.PeerEntryObj{Index: i, Name: peerInfo.Name, IP: peerInfo.IP})
94 94
 			}
95 95
 		}
96
-		log.WithField("response", fmt.Sprintf("%+v", rsp)).Info("network peers done")
96
+		logger.WithField("response", fmt.Sprintf("%+v", rsp)).Info("network peers done")
97 97
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json)
98 98
 		return
99 99
 	}
... ...
@@ -101,13 +110,18 @@ func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
101 101
 }
102 102
 
103 103
 func dbClusterPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
104
-	r.ParseForm()
104
+	_ = r.ParseForm()
105 105
 	diagnostic.DebugHTTPForm(r)
106 106
 	_, json := diagnostic.ParseHTTPFormOptions(r)
107 107
 
108 108
 	// audit logs
109
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
110
-	log.Info("cluster peers")
109
+	logger := log.G(context.TODO()).WithFields(log.Fields{
110
+		"component": "diagnostic",
111
+		"remoteIP":  r.RemoteAddr,
112
+		"method":    caller.Name(0),
113
+		"url":       r.URL.String(),
114
+	})
115
+	logger.Info("cluster peers")
111 116
 
112 117
 	nDB, ok := ctx.(*NetworkDB)
113 118
 	if ok {
... ...
@@ -116,7 +130,7 @@ func dbClusterPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
116 116
 		for i, peerInfo := range peers {
117 117
 			rsp.Elements = append(rsp.Elements, &diagnostic.PeerEntryObj{Index: i, Name: peerInfo.Name, IP: peerInfo.IP})
118 118
 		}
119
-		log.WithField("response", fmt.Sprintf("%+v", rsp)).Info("cluster peers done")
119
+		logger.WithField("response", fmt.Sprintf("%+v", rsp)).Info("cluster peers done")
120 120
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json)
121 121
 		return
122 122
 	}
... ...
@@ -124,20 +138,25 @@ func dbClusterPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
124 124
 }
125 125
 
126 126
 func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
127
-	r.ParseForm()
127
+	_ = r.ParseForm()
128 128
 	diagnostic.DebugHTTPForm(r)
129 129
 	unsafe, json := diagnostic.ParseHTTPFormOptions(r)
130 130
 
131 131
 	// audit logs
132
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
133
-	log.Info("create entry")
132
+	logger := log.G(context.TODO()).WithFields(log.Fields{
133
+		"component": "diagnostic",
134
+		"remoteIP":  r.RemoteAddr,
135
+		"method":    caller.Name(0),
136
+		"url":       r.URL.String(),
137
+	})
138
+	logger.Info("create entry")
134 139
 
135 140
 	if len(r.Form["tname"]) < 1 ||
136 141
 		len(r.Form["nid"]) < 1 ||
137 142
 		len(r.Form["key"]) < 1 ||
138 143
 		len(r.Form["value"]) < 1 {
139 144
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k&value=v", r.URL.Path))
140
-		log.Error("create entry failed, wrong input")
145
+		logger.Error("create entry failed, wrong input")
141 146
 		diagnostic.HTTPReply(w, rsp, json)
142 147
 		return
143 148
 	}
... ...
@@ -151,7 +170,7 @@ func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
151 151
 		var err error
152 152
 		decodedValue, err = base64.StdEncoding.DecodeString(value)
153 153
 		if err != nil {
154
-			log.WithError(err).Error("create entry failed")
154
+			logger.WithError(err).Error("create entry failed")
155 155
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
156 156
 			return
157 157
 		}
... ...
@@ -162,10 +181,10 @@ func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
162 162
 		if err := nDB.CreateEntry(tname, nid, key, decodedValue); err != nil {
163 163
 			rsp := diagnostic.FailCommand(err)
164 164
 			diagnostic.HTTPReply(w, rsp, json)
165
-			log.WithError(err).Error("create entry failed")
165
+			logger.WithError(err).Error("create entry failed")
166 166
 			return
167 167
 		}
168
-		log.Info("create entry done")
168
+		logger.Info("create entry done")
169 169
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json)
170 170
 		return
171 171
 	}
... ...
@@ -173,20 +192,25 @@ func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
173 173
 }
174 174
 
175 175
 func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
176
-	r.ParseForm()
176
+	_ = r.ParseForm()
177 177
 	diagnostic.DebugHTTPForm(r)
178 178
 	unsafe, json := diagnostic.ParseHTTPFormOptions(r)
179 179
 
180 180
 	// audit logs
181
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
182
-	log.Info("update entry")
181
+	logger := log.G(context.TODO()).WithFields(log.Fields{
182
+		"component": "diagnostic",
183
+		"remoteIP":  r.RemoteAddr,
184
+		"method":    caller.Name(0),
185
+		"url":       r.URL.String(),
186
+	})
187
+	logger.Info("update entry")
183 188
 
184 189
 	if len(r.Form["tname"]) < 1 ||
185 190
 		len(r.Form["nid"]) < 1 ||
186 191
 		len(r.Form["key"]) < 1 ||
187 192
 		len(r.Form["value"]) < 1 {
188 193
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k&value=v", r.URL.Path))
189
-		log.Error("update entry failed, wrong input")
194
+		logger.Error("update entry failed, wrong input")
190 195
 		diagnostic.HTTPReply(w, rsp, json)
191 196
 		return
192 197
 	}
... ...
@@ -200,7 +224,7 @@ func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
200 200
 		var err error
201 201
 		decodedValue, err = base64.StdEncoding.DecodeString(value)
202 202
 		if err != nil {
203
-			log.WithError(err).Error("update entry failed")
203
+			logger.WithError(err).Error("update entry failed")
204 204
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
205 205
 			return
206 206
 		}
... ...
@@ -209,11 +233,11 @@ func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
209 209
 	nDB, ok := ctx.(*NetworkDB)
210 210
 	if ok {
211 211
 		if err := nDB.UpdateEntry(tname, nid, key, decodedValue); err != nil {
212
-			log.WithError(err).Error("update entry failed")
212
+			logger.WithError(err).Error("update entry failed")
213 213
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
214 214
 			return
215 215
 		}
216
-		log.Info("update entry done")
216
+		logger.Info("update entry done")
217 217
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json)
218 218
 		return
219 219
 	}
... ...
@@ -221,19 +245,24 @@ func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
221 221
 }
222 222
 
223 223
 func dbDeleteEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
224
-	r.ParseForm()
224
+	_ = r.ParseForm()
225 225
 	diagnostic.DebugHTTPForm(r)
226 226
 	_, json := diagnostic.ParseHTTPFormOptions(r)
227 227
 
228 228
 	// audit logs
229
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
230
-	log.Info("delete entry")
229
+	logger := log.G(context.TODO()).WithFields(log.Fields{
230
+		"component": "diagnostic",
231
+		"remoteIP":  r.RemoteAddr,
232
+		"method":    caller.Name(0),
233
+		"url":       r.URL.String(),
234
+	})
235
+	logger.Info("delete entry")
231 236
 
232 237
 	if len(r.Form["tname"]) < 1 ||
233 238
 		len(r.Form["nid"]) < 1 ||
234 239
 		len(r.Form["key"]) < 1 {
235 240
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k", r.URL.Path))
236
-		log.Error("delete entry failed, wrong input")
241
+		logger.Error("delete entry failed, wrong input")
237 242
 		diagnostic.HTTPReply(w, rsp, json)
238 243
 		return
239 244
 	}
... ...
@@ -246,11 +275,11 @@ func dbDeleteEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
246 246
 	if ok {
247 247
 		err := nDB.DeleteEntry(tname, nid, key)
248 248
 		if err != nil {
249
-			log.WithError(err).Error("delete entry failed")
249
+			logger.WithError(err).Error("delete entry failed")
250 250
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
251 251
 			return
252 252
 		}
253
-		log.Info("delete entry done")
253
+		logger.Info("delete entry done")
254 254
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json)
255 255
 		return
256 256
 	}
... ...
@@ -258,19 +287,24 @@ func dbDeleteEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
258 258
 }
259 259
 
260 260
 func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
261
-	r.ParseForm()
261
+	_ = r.ParseForm()
262 262
 	diagnostic.DebugHTTPForm(r)
263 263
 	unsafe, json := diagnostic.ParseHTTPFormOptions(r)
264 264
 
265 265
 	// audit logs
266
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
267
-	log.Info("get entry")
266
+	logger := log.G(context.TODO()).WithFields(log.Fields{
267
+		"component": "diagnostic",
268
+		"remoteIP":  r.RemoteAddr,
269
+		"method":    caller.Name(0),
270
+		"url":       r.URL.String(),
271
+	})
272
+	logger.Info("get entry")
268 273
 
269 274
 	if len(r.Form["tname"]) < 1 ||
270 275
 		len(r.Form["nid"]) < 1 ||
271 276
 		len(r.Form["key"]) < 1 {
272 277
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id&key=k", r.URL.Path))
273
-		log.Error("get entry failed, wrong input")
278
+		logger.Error("get entry failed, wrong input")
274 279
 		diagnostic.HTTPReply(w, rsp, json)
275 280
 		return
276 281
 	}
... ...
@@ -283,7 +317,7 @@ func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
283 283
 	if ok {
284 284
 		value, err := nDB.GetEntry(tname, nid, key)
285 285
 		if err != nil {
286
-			log.WithError(err).Error("get entry failed")
286
+			logger.WithError(err).Error("get entry failed")
287 287
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
288 288
 			return
289 289
 		}
... ...
@@ -296,7 +330,7 @@ func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
296 296
 		}
297 297
 
298 298
 		rsp := &diagnostic.TableEntryObj{Key: key, Value: encodedValue}
299
-		log.WithField("response", fmt.Sprintf("%+v", rsp)).Info("get entry done")
299
+		logger.WithField("response", fmt.Sprintf("%+v", rsp)).Info("get entry done")
300 300
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json)
301 301
 		return
302 302
 	}
... ...
@@ -304,17 +338,22 @@ func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) {
304 304
 }
305 305
 
306 306
 func dbJoinNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) {
307
-	r.ParseForm()
307
+	_ = r.ParseForm()
308 308
 	diagnostic.DebugHTTPForm(r)
309 309
 	_, json := diagnostic.ParseHTTPFormOptions(r)
310 310
 
311 311
 	// audit logs
312
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
313
-	log.Info("join network")
312
+	logger := log.G(context.TODO()).WithFields(log.Fields{
313
+		"component": "diagnostic",
314
+		"remoteIP":  r.RemoteAddr,
315
+		"method":    caller.Name(0),
316
+		"url":       r.URL.String(),
317
+	})
318
+	logger.Info("join network")
314 319
 
315 320
 	if len(r.Form["nid"]) < 1 {
316 321
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?nid=network_id", r.URL.Path))
317
-		log.Error("join network failed, wrong input")
322
+		logger.Error("join network failed, wrong input")
318 323
 		diagnostic.HTTPReply(w, rsp, json)
319 324
 		return
320 325
 	}
... ...
@@ -324,11 +363,11 @@ func dbJoinNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) {
324 324
 	nDB, ok := ctx.(*NetworkDB)
325 325
 	if ok {
326 326
 		if err := nDB.JoinNetwork(nid); err != nil {
327
-			log.WithError(err).Error("join network failed")
327
+			logger.WithError(err).Error("join network failed")
328 328
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
329 329
 			return
330 330
 		}
331
-		log.Info("join network done")
331
+		logger.Info("join network done")
332 332
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json)
333 333
 		return
334 334
 	}
... ...
@@ -336,17 +375,22 @@ func dbJoinNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) {
336 336
 }
337 337
 
338 338
 func dbLeaveNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) {
339
-	r.ParseForm()
339
+	_ = r.ParseForm()
340 340
 	diagnostic.DebugHTTPForm(r)
341 341
 	_, json := diagnostic.ParseHTTPFormOptions(r)
342 342
 
343 343
 	// audit logs
344
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
345
-	log.Info("leave network")
344
+	logger := log.G(context.TODO()).WithFields(log.Fields{
345
+		"component": "diagnostic",
346
+		"remoteIP":  r.RemoteAddr,
347
+		"method":    caller.Name(0),
348
+		"url":       r.URL.String(),
349
+	})
350
+	logger.Info("leave network")
346 351
 
347 352
 	if len(r.Form["nid"]) < 1 {
348 353
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?nid=network_id", r.URL.Path))
349
-		log.Error("leave network failed, wrong input")
354
+		logger.Error("leave network failed, wrong input")
350 355
 		diagnostic.HTTPReply(w, rsp, json)
351 356
 		return
352 357
 	}
... ...
@@ -356,11 +400,11 @@ func dbLeaveNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) {
356 356
 	nDB, ok := ctx.(*NetworkDB)
357 357
 	if ok {
358 358
 		if err := nDB.LeaveNetwork(nid); err != nil {
359
-			log.WithError(err).Error("leave network failed")
359
+			logger.WithError(err).Error("leave network failed")
360 360
 			diagnostic.HTTPReply(w, diagnostic.FailCommand(err), json)
361 361
 			return
362 362
 		}
363
-		log.Info("leave network done")
363
+		logger.Info("leave network done")
364 364
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json)
365 365
 		return
366 366
 	}
... ...
@@ -368,18 +412,23 @@ func dbLeaveNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) {
368 368
 }
369 369
 
370 370
 func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
371
-	r.ParseForm()
371
+	_ = r.ParseForm()
372 372
 	diagnostic.DebugHTTPForm(r)
373 373
 	unsafe, json := diagnostic.ParseHTTPFormOptions(r)
374 374
 
375 375
 	// audit logs
376
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
377
-	log.Info("get table")
376
+	logger := log.G(context.TODO()).WithFields(log.Fields{
377
+		"component": "diagnostic",
378
+		"remoteIP":  r.RemoteAddr,
379
+		"method":    caller.Name(0),
380
+		"url":       r.URL.String(),
381
+	})
382
+	logger.Info("get table")
378 383
 
379 384
 	if len(r.Form["tname"]) < 1 ||
380 385
 		len(r.Form["nid"]) < 1 {
381 386
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name&nid=network_id", r.URL.Path))
382
-		log.Error("get table failed, wrong input")
387
+		logger.Error("get table failed, wrong input")
383 388
 		diagnostic.HTTPReply(w, rsp, json)
384 389
 		return
385 390
 	}
... ...
@@ -408,7 +457,7 @@ func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
408 408
 				})
409 409
 			i++
410 410
 		}
411
-		log.WithField("response", fmt.Sprintf("%+v", rsp)).Info("get table done")
411
+		logger.WithField("response", fmt.Sprintf("%+v", rsp)).Info("get table done")
412 412
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json)
413 413
 		return
414 414
 	}
... ...
@@ -416,17 +465,22 @@ func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
416 416
 }
417 417
 
418 418
 func dbNetworkStats(ctx interface{}, w http.ResponseWriter, r *http.Request) {
419
-	r.ParseForm()
419
+	_ = r.ParseForm()
420 420
 	diagnostic.DebugHTTPForm(r)
421 421
 	_, json := diagnostic.ParseHTTPFormOptions(r)
422 422
 
423 423
 	// audit logs
424
-	log := log.G(context.TODO()).WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
425
-	log.Info("network stats")
424
+	logger := log.G(context.TODO()).WithFields(log.Fields{
425
+		"component": "diagnostic",
426
+		"remoteIP":  r.RemoteAddr,
427
+		"method":    caller.Name(0),
428
+		"url":       r.URL.String(),
429
+	})
430
+	logger.Info("network stats")
426 431
 
427 432
 	if len(r.Form["nid"]) < 1 {
428 433
 		rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?nid=test", r.URL.Path))
429
-		log.Error("network stats failed, wrong input")
434
+		logger.Error("network stats failed, wrong input")
430 435
 		diagnostic.HTTPReply(w, rsp, json)
431 436
 		return
432 437
 	}
... ...
@@ -446,7 +500,7 @@ func dbNetworkStats(ctx interface{}, w http.ResponseWriter, r *http.Request) {
446 446
 		nDB.RUnlock()
447 447
 
448 448
 		rsp := diagnostic.CommandSucceed(&diagnostic.NetworkStatsResult{Entries: entries, QueueLen: qLen})
449
-		log.WithField("response", fmt.Sprintf("%+v", rsp)).Info("network stats done")
449
+		logger.WithField("response", fmt.Sprintf("%+v", rsp)).Info("network stats done")
450 450
 		diagnostic.HTTPReply(w, rsp, json)
451 451
 		return
452 452
 	}
... ...
@@ -522,12 +522,12 @@ func (r *Resolver) exchange(proto string, extDNS extDNSEntry, query *dns.Msg) *d
522 522
 	}
523 523
 	defer extConn.Close()
524 524
 
525
-	log := r.log().WithFields(logrus.Fields{
525
+	logger := r.log().WithFields(log.Fields{
526 526
 		"dns-server":  extConn.RemoteAddr().Network() + ":" + extConn.RemoteAddr().String(),
527 527
 		"client-addr": extConn.LocalAddr().Network() + ":" + extConn.LocalAddr().String(),
528 528
 		"question":    query.Question[0].String(),
529 529
 	})
530
-	log.Debug("[resolver] forwarding query")
530
+	logger.Debug("[resolver] forwarding query")
531 531
 
532 532
 	resp, _, err := (&dns.Client{
533 533
 		Timeout: extIOTimeout,
... ...
@@ -549,7 +549,7 @@ func (r *Resolver) exchange(proto string, extDNS extDNSEntry, query *dns.Msg) *d
549 549
 
550 550
 	if resp == nil {
551 551
 		// Should be impossible, so make noise if it happens anyway.
552
-		log.Error("[resolver] external DNS returned empty response")
552
+		logger.Error("[resolver] external DNS returned empty response")
553 553
 	}
554 554
 	return resp
555 555
 }
... ...
@@ -30,7 +30,6 @@ import (
30 30
 	"github.com/moby/patternmatcher"
31 31
 	"github.com/moby/sys/sequential"
32 32
 	"github.com/pkg/errors"
33
-	"github.com/sirupsen/logrus"
34 33
 )
35 34
 
36 35
 // ImpliedDirectoryMode represents the mode (Unix permissions) applied to directories that are implied by files in a
... ...
@@ -790,7 +789,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, o
790 790
 	}
791 791
 
792 792
 	if len(xattrErrs) > 0 {
793
-		log.G(context.TODO()).WithFields(logrus.Fields{
793
+		log.G(context.TODO()).WithFields(log.Fields{
794 794
 			"errors": xattrErrs,
795 795
 		}).Warn("ignored xattrs in archive: underlying filesystem doesn't support them")
796 796
 	}
... ...
@@ -76,13 +76,12 @@ func (p c8dPlugin) deleteTaskAndContainer(ctx context.Context) {
76 76
 // Create creates a new container
77 77
 func (e *Executor) Create(id string, spec specs.Spec, stdout, stderr io.WriteCloser) error {
78 78
 	ctx := context.Background()
79
-	log := log.G(ctx).WithField("plugin", id)
80 79
 	ctr, err := libcontainerd.ReplaceContainer(ctx, e.client, id, &spec, e.shim, e.shimOpts)
81 80
 	if err != nil {
82 81
 		return errors.Wrap(err, "error creating containerd container for plugin")
83 82
 	}
84 83
 
85
-	p := c8dPlugin{log: log, ctr: ctr}
84
+	p := c8dPlugin{log: log.G(ctx).WithField("plugin", id), ctr: ctr}
86 85
 	p.tsk, err = ctr.Start(ctx, "", false, attachStreamsFunc(stdout, stderr))
87 86
 	if err != nil {
88 87
 		p.deleteTaskAndContainer(ctx)
... ...
@@ -311,7 +311,7 @@ func (logHook) Levels() []logrus.Level {
311 311
 }
312 312
 
313 313
 func (l logHook) Fire(entry *logrus.Entry) error {
314
-	entry.Data = logrus.Fields{"plugin": l.id}
314
+	entry.Data = log.Fields{"plugin": l.id}
315 315
 	return nil
316 316
 }
317 317
 
... ...
@@ -1,15 +1,16 @@
1 1
 package registry // import "github.com/docker/docker/registry"
2 2
 
3 3
 import (
4
+	"context"
4 5
 	"net"
5 6
 	"net/url"
6 7
 	"regexp"
7 8
 	"strconv"
8 9
 	"strings"
9 10
 
11
+	"github.com/containerd/containerd/log"
10 12
 	"github.com/docker/distribution/reference"
11 13
 	"github.com/docker/docker/api/types/registry"
12
-	"github.com/sirupsen/logrus"
13 14
 )
14 15
 
15 16
 // ServiceOptions holds command line options.
... ...
@@ -197,10 +198,10 @@ skip:
197 197
 			return err
198 198
 		}
199 199
 		if strings.HasPrefix(strings.ToLower(r), "http://") {
200
-			logrus.Warnf("insecure registry %s should not contain 'http://' and 'http://' has been removed from the insecure registry config", r)
200
+			log.G(context.TODO()).Warnf("insecure registry %s should not contain 'http://' and 'http://' has been removed from the insecure registry config", r)
201 201
 			r = r[7:]
202 202
 		} else if strings.HasPrefix(strings.ToLower(r), "https://") {
203
-			logrus.Warnf("insecure registry %s should not contain 'https://' and 'https://' has been removed from the insecure registry config", r)
203
+			log.G(context.TODO()).Warnf("insecure registry %s should not contain 'https://' and 'https://' has been removed from the insecure registry config", r)
204 204
 			r = r[8:]
205 205
 		} else if hasScheme(r) {
206 206
 			return invalidParamf("insecure registry %s should not contain '://'", r)
... ...
@@ -19,7 +19,6 @@ import (
19 19
 	"github.com/docker/docker/quota"
20 20
 	"github.com/docker/docker/volume"
21 21
 	"github.com/pkg/errors"
22
-	"github.com/sirupsen/logrus"
23 22
 )
24 23
 
25 24
 const (
... ...
@@ -390,7 +389,7 @@ func (v *localVolume) LiveRestoreVolume(ctx context.Context, _ string) error {
390 390
 	}
391 391
 	v.active.count++
392 392
 	v.active.mounted = true
393
-	log.G(ctx).WithFields(logrus.Fields{
393
+	log.G(ctx).WithFields(log.Fields{
394 394
 		"volume":        v.name,
395 395
 		"active mounts": v.active,
396 396
 	}).Debugf("Live restored volume")
... ...
@@ -14,7 +14,6 @@ import (
14 14
 	"github.com/docker/docker/volume"
15 15
 	"github.com/opencontainers/selinux/go-selinux/label"
16 16
 	"github.com/pkg/errors"
17
-	"github.com/sirupsen/logrus"
18 17
 )
19 18
 
20 19
 // MountPoint is the intersection point between a volume and a container. It
... ...
@@ -169,7 +168,7 @@ func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.Identity, checkFun
169 169
 
170 170
 func (m *MountPoint) LiveRestore(ctx context.Context) error {
171 171
 	if m.Volume == nil {
172
-		logrus.Debug("No volume to restore")
172
+		log.G(ctx).Debug("No volume to restore")
173 173
 		return nil
174 174
 	}
175 175