diff --git a/api/client/attach.go b/api/client/attach.go index a2d0cd85bdc12fbd457d7ff8997ba289d6a46588..e6acec48b4a9940284464dc97ab202edc7329645 100644 --- a/api/client/attach.go +++ b/api/client/attach.go @@ -5,7 +5,7 @@ import ( "io" "net/url" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/signal" @@ -51,7 +51,7 @@ func (cli *DockerCli) CmdAttach(args ...string) error { if tty && cli.isTerminalOut { if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil { - log.Debugf("Error monitoring TTY size: %s", err) + logrus.Debugf("Error monitoring TTY size: %s", err) } } diff --git a/api/client/build.go b/api/client/build.go index df5ca9b1fe9a088c4af60d586e1c7e3dd5f4a341..779e98ecc700dc943b374ac5fd50f1dfd7576c5a 100644 --- a/api/client/build.go +++ b/api/client/build.go @@ -17,7 +17,7 @@ import ( "strconv" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/graph" "github.com/docker/docker/pkg/archive" @@ -198,7 +198,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error { // windows: show error message about modified file permissions // FIXME: this is not a valid warning when the daemon is running windows. should be removed once docker engine for windows can build. if runtime.GOOS == "windows" { - log.Warn(`SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`) + logrus.Warn(`SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`) } var body io.Reader diff --git a/api/client/exec.go b/api/client/exec.go index c0d8ec0f72271d7a0cd9a278321f7d6684145be8..27e6878df4302711d3ae76c31dd98e2217c22567 100644 --- a/api/client/exec.go +++ b/api/client/exec.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/runconfig" @@ -67,9 +67,9 @@ func (cli *DockerCli) CmdExec(args ...string) error { // Block the return until the chan gets closed defer func() { - log.Debugf("End of CmdExec(), Waiting for hijack to finish.") + logrus.Debugf("End of CmdExec(), Waiting for hijack to finish.") if _, ok := <-hijacked; ok { - log.Errorf("Hijack did not finish (chan still open)") + logrus.Errorf("Hijack did not finish (chan still open)") } }() @@ -100,19 +100,19 @@ func (cli *DockerCli) CmdExec(args ...string) error { } case err := <-errCh: if err != nil { - log.Debugf("Error hijack: %s", err) + logrus.Debugf("Error hijack: %s", err) return err } } if execConfig.Tty && cli.isTerminalIn { if err := cli.monitorTtySize(execID, true); err != nil { - log.Errorf("Error monitoring TTY size: %s", err) + logrus.Errorf("Error monitoring TTY size: %s", err) } } if err := <-errCh; err != nil { - log.Debugf("Error hijack: %s", err) + logrus.Debugf("Error hijack: %s", err) return err } diff --git a/api/client/hijack.go b/api/client/hijack.go index 4f89c3a76ce93be2a16a1781d3fcf9375288c21a..16353841687973e6b8e215289a810fb5c7458f7f 100644 --- a/api/client/hijack.go +++ b/api/client/hijack.go @@ -13,7 +13,7 @@ import ( "strings" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/pkg/promise" @@ -211,7 +211,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea } else { _, err = stdcopy.StdCopy(stdout, stderr, br) } - log.Debugf("[hijack] End of stdout") + logrus.Debugf("[hijack] End of stdout") return err }) } @@ -219,14 +219,14 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea sendStdin := promise.Go(func() error { if in != nil { io.Copy(rwc, in) - log.Debugf("[hijack] End of stdin") + logrus.Debugf("[hijack] End of stdin") } if conn, ok := rwc.(interface { CloseWrite() error }); ok { if err := conn.CloseWrite(); err != nil { - log.Debugf("Couldn't send EOF: %s", err) + logrus.Debugf("Couldn't send EOF: %s", err) } } // Discard errors due to pipe interruption @@ -235,14 +235,14 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea if stdout != nil || stderr != nil { if err := <-receiveStdout; err != nil { - log.Debugf("Error receiveStdout: %s", err) + logrus.Debugf("Error receiveStdout: %s", err) return err } } if !cli.isTerminalIn { if err := <-sendStdin; err != nil { - log.Debugf("Error sendStdin: %s", err) + logrus.Debugf("Error sendStdin: %s", err) return err } } diff --git a/api/client/info.go b/api/client/info.go index 7544742746be850700b94617f3aa39aaf68046ff..7a350e32acea5c57a41b393d0af081265489f36d 100644 --- a/api/client/info.go +++ b/api/client/info.go @@ -5,7 +5,7 @@ import ( "os" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/units" @@ -32,7 +32,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error { } if _, err := out.Write(body); err != nil { - log.Errorf("Error reading remote info: %s", err) + logrus.Errorf("Error reading remote info: %s", err) return err } out.Close() @@ -91,7 +91,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error { if remoteInfo.Exists("SystemTime") { t, err := remoteInfo.GetTime("SystemTime") if err != nil { - log.Errorf("Error reading system time: %v", err) + logrus.Errorf("Error reading system time: %v", err) } else { fmt.Fprintf(cli.out, "System Time: %s\n", t.Format(time.UnixDate)) } diff --git a/api/client/run.go b/api/client/run.go index 650fe4a184680c063417f689214223320aee7742..b13ffd937c7a31b2dc6edf929efff20dc1d7923f 100644 --- a/api/client/run.go +++ b/api/client/run.go @@ -6,7 +6,7 @@ import ( "net/url" "os" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/resolvconf" @@ -132,9 +132,9 @@ func (cli *DockerCli) CmdRun(args ...string) error { hijacked := make(chan io.Closer) // Block the return until the chan gets closed defer func() { - log.Debugf("End of CmdRun(), Waiting for hijack to finish.") + logrus.Debugf("End of CmdRun(), Waiting for hijack to finish.") if _, ok := <-hijacked; ok { - log.Errorf("Hijack did not finish (chan still open)") + logrus.Errorf("Hijack did not finish (chan still open)") } }() if config.AttachStdin || config.AttachStdout || config.AttachStderr { @@ -176,7 +176,7 @@ func (cli *DockerCli) CmdRun(args ...string) error { } case err := <-errCh: if err != nil { - log.Debugf("Error hijack: %s", err) + logrus.Debugf("Error hijack: %s", err) return err } } @@ -184,7 +184,7 @@ func (cli *DockerCli) CmdRun(args ...string) error { defer func() { if *flAutoRemove { if _, _, err = readBody(cli.call("DELETE", "/containers/"+createResponse.ID+"?v=1", nil, nil)); err != nil { - log.Errorf("Error deleting container: %s", err) + logrus.Errorf("Error deleting container: %s", err) } } }() @@ -196,13 +196,13 @@ func (cli *DockerCli) CmdRun(args ...string) error { if (config.AttachStdin || config.AttachStdout || config.AttachStderr) && config.Tty && cli.isTerminalOut { if err := cli.monitorTtySize(createResponse.ID, false); err != nil { - log.Errorf("Error monitoring TTY size: %s", err) + logrus.Errorf("Error monitoring TTY size: %s", err) } } if errCh != nil { if err := <-errCh; err != nil { - log.Debugf("Error hijack: %s", err) + logrus.Debugf("Error hijack: %s", err) return err } } diff --git a/api/client/start.go b/api/client/start.go index 42a42655528cac78a72128dce10d43ecaa653ed1..554b7bcfa46e57f8e17bceaa674a7de64652058a 100644 --- a/api/client/start.go +++ b/api/client/start.go @@ -6,7 +6,7 @@ import ( "net/url" "os" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/promise" @@ -30,10 +30,10 @@ func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal { } } if sig == "" { - log.Errorf("Unsupported signal: %v. Discarding.", s) + logrus.Errorf("Unsupported signal: %v. Discarding.", s) } if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", cid, sig), nil, nil)); err != nil { - log.Debugf("Error sending signal: %s", err) + logrus.Debugf("Error sending signal: %s", err) } } }() @@ -94,9 +94,9 @@ func (cli *DockerCli) CmdStart(args ...string) error { hijacked := make(chan io.Closer) // Block the return until the chan gets closed defer func() { - log.Debugf("CmdStart() returned, defer waiting for hijack to finish.") + logrus.Debugf("CmdStart() returned, defer waiting for hijack to finish.") if _, ok := <-hijacked; ok { - log.Errorf("Hijack did not finish (chan still open)") + logrus.Errorf("Hijack did not finish (chan still open)") } cli.in.Close() }() @@ -145,7 +145,7 @@ func (cli *DockerCli) CmdStart(args ...string) error { if *openStdin || *attach { if tty && cli.isTerminalOut { if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil { - log.Errorf("Error monitoring TTY size: %s", err) + logrus.Errorf("Error monitoring TTY size: %s", err) } } if attchErr := <-cErr; attchErr != nil { diff --git a/api/client/utils.go b/api/client/utils.go index 7ce0592ed6d8e76525ed624a72c39c08620dfbf0..8c53a2d5dab388ff7430dffb1f51bfd8023bd11d 100644 --- a/api/client/utils.go +++ b/api/client/utils.go @@ -15,7 +15,7 @@ import ( "strconv" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/engine" @@ -195,7 +195,7 @@ func (cli *DockerCli) streamBody(body io.ReadCloser, contentType string, setRawT } else { _, err = stdcopy.StdCopy(stdout, stderr, body) } - log.Debugf("[stream] End of stdout") + logrus.Debugf("[stream] End of stdout") return err } return nil @@ -218,7 +218,7 @@ func (cli *DockerCli) resizeTty(id string, isExec bool) { } if _, _, err := readBody(cli.call("POST", path+v.Encode(), nil, nil)); err != nil { - log.Debugf("Error resize: %s", err) + logrus.Debugf("Error resize: %s", err) } } @@ -295,7 +295,7 @@ func (cli *DockerCli) getTtySize() (int, int) { } ws, err := term.GetWinsize(cli.outFd) if err != nil { - log.Debugf("Error getting size: %s", err) + logrus.Debugf("Error getting size: %s", err) if ws == nil { return 0, 0 } diff --git a/api/client/version.go b/api/client/version.go index 491b3c4ed228c21e573b4590f1873c4c579ef521..f3fea96a094fe9ba8764b987cb8a65a47ef32e55 100644 --- a/api/client/version.go +++ b/api/client/version.go @@ -4,7 +4,7 @@ import ( "fmt" "runtime" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/engine" @@ -41,11 +41,11 @@ func (cli *DockerCli) CmdVersion(args ...string) error { out := engine.NewOutput() remoteVersion, err := out.AddEnv() if err != nil { - log.Errorf("Error reading remote version: %s", err) + logrus.Errorf("Error reading remote version: %s", err) return err } if _, err := out.Write(body); err != nil { - log.Errorf("Error reading remote version: %s", err) + logrus.Errorf("Error reading remote version: %s", err) return err } out.Close() diff --git a/api/common.go b/api/common.go index a0f44e860c6af5d64c4cacdba39e5998778b9879..8cffa086e508c2530a804239f01fb355a3c752de 100644 --- a/api/common.go +++ b/api/common.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/version" @@ -105,7 +105,7 @@ func FormGroup(key string, start, last int) string { func MatchesContentType(contentType, expectedType string) bool { mimetype, _, err := mime.ParseMediaType(contentType) if err != nil { - log.Errorf("Error parsing media type: %s error: %v", contentType, err) + logrus.Errorf("Error parsing media type: %s error: %v", contentType, err) } return err == nil && mimetype == expectedType } diff --git a/api/server/server.go b/api/server/server.go index c52c6bd2afd0f537bb3e266d42d7a0db7a4cc02f..2dabbbebad39d7181f50259fbcc23c0d7e9d768a 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -24,7 +24,7 @@ import ( "github.com/docker/libcontainer/user" "github.com/gorilla/mux" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/daemon/networkdriver/portallocator" @@ -135,7 +135,7 @@ func httpError(w http.ResponseWriter, err error) { } if err != nil { - log.Errorf("HTTP Error: statusCode=%d %v", statusCode, err) + logrus.Errorf("HTTP Error: statusCode=%d %v", statusCode, err) http.Error(w, err.Error(), statusCode) } } @@ -517,7 +517,7 @@ func postCommit(eng *engine.Engine, version version.Version, w http.ResponseWrit } if err := config.Decode(r.Body); err != nil { - log.Errorf("%s", err) + logrus.Errorf("%s", err) } if r.FormValue("pause") == "" && version.GreaterThanOrEqualTo("1.13") { @@ -987,7 +987,7 @@ func wsContainersAttach(eng *engine.Engine, version version.Version, w http.Resp job.Stdout.Add(ws) job.Stderr.Set(ws) if err := job.Run(); err != nil { - log.Errorf("Error attaching websocket: %s", err) + logrus.Errorf("Error attaching websocket: %s", err) } }) h.ServeHTTP(w, r) @@ -1101,7 +1101,7 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite select { case <-finished: case <-closeNotifier.CloseNotify(): - log.Infof("Client disconnected, cancelling job: %s", job.Name) + logrus.Infof("Client disconnected, cancelling job: %s", job.Name) job.Cancel() } }() @@ -1146,7 +1146,7 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp job.Stdout.Add(w) w.Header().Set("Content-Type", "application/x-tar") if err := job.Run(); err != nil { - log.Errorf("%v", err) + logrus.Errorf("%v", err) if strings.Contains(strings.ToLower(err.Error()), "no such id") { w.WriteHeader(http.StatusNotFound) } else if strings.Contains(err.Error(), "no such file or directory") { @@ -1262,7 +1262,7 @@ func optionsHandler(eng *engine.Engine, version version.Version, w http.Response return nil } func writeCorsHeaders(w http.ResponseWriter, r *http.Request, corsHeaders string) { - log.Debugf("CORS header is enabled and set to: %s", corsHeaders) + logrus.Debugf("CORS header is enabled and set to: %s", corsHeaders) w.Header().Add("Access-Control-Allow-Origin", corsHeaders) w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth") w.Header().Add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS") @@ -1276,16 +1276,16 @@ func ping(eng *engine.Engine, version version.Version, w http.ResponseWriter, r func makeHttpHandler(eng *engine.Engine, logging bool, localMethod string, localRoute string, handlerFunc HttpApiFunc, corsHeaders string, dockerVersion version.Version) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // log the request - log.Debugf("Calling %s %s", localMethod, localRoute) + logrus.Debugf("Calling %s %s", localMethod, localRoute) if logging { - log.Infof("%s %s", r.Method, r.RequestURI) + logrus.Infof("%s %s", r.Method, r.RequestURI) } if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") { userAgent := strings.Split(r.Header.Get("User-Agent"), "/") if len(userAgent) == 2 && !dockerVersion.Equal(version.Version(userAgent[1])) { - log.Debugf("Warning: client and server don't have the same version (client: %s, server: %s)", userAgent[1], dockerVersion) + logrus.Debugf("Warning: client and server don't have the same version (client: %s, server: %s)", userAgent[1], dockerVersion) } } version := version.Version(mux.Vars(r)["version"]) @@ -1302,7 +1302,7 @@ func makeHttpHandler(eng *engine.Engine, logging bool, localMethod string, local } if err := handlerFunc(eng, version, w, r, mux.Vars(r)); err != nil { - log.Errorf("Handler for %s %s returned error: %s", localMethod, localRoute, err) + logrus.Errorf("Handler for %s %s returned error: %s", localMethod, localRoute, err) httpError(w, err) } } @@ -1406,7 +1406,7 @@ func createRouter(eng *engine.Engine, logging, enableCors bool, corsHeaders stri for method, routes := range m { for route, fct := range routes { - log.Debugf("Registering %s, %s", method, route) + logrus.Debugf("Registering %s, %s", method, route) // NOTE: scope issue, make sure the variables are local and won't be changed localRoute := route localFct := fct @@ -1454,7 +1454,7 @@ func lookupGidByName(nameOrGid string) (int, error) { } gid, err := strconv.Atoi(nameOrGid) if err == nil { - log.Warnf("Could not find GID %d", gid) + logrus.Warnf("Could not find GID %d", gid) return gid, nil } return -1, fmt.Errorf("Group %s not found", nameOrGid) @@ -1504,7 +1504,7 @@ func changeGroup(addr string, nameOrGid string) error { return err } - log.Debugf("%s group found. gid: %d", nameOrGid, gid) + logrus.Debugf("%s group found. gid: %d", nameOrGid, gid) return os.Chown(addr, 0, gid) } @@ -1517,7 +1517,7 @@ func setSocketGroup(addr, group string) error { if group != "docker" { return err } - log.Debugf("Warning: could not chgrp %s to docker: %v", addr, err) + logrus.Debugf("Warning: could not chgrp %s to docker: %v", addr, err) } return nil @@ -1551,7 +1551,7 @@ func allocateDaemonPort(addr string) error { func setupTcpHttp(addr string, job *engine.Job) (*HttpServer, error) { if !job.GetenvBool("TlsVerify") { - log.Infof("/!\\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\") + logrus.Infof("/!\\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\") } r := createRouter(job.Eng, job.GetenvBool("Logging"), job.GetenvBool("EnableCors"), job.Getenv("CorsHeaders"), job.Getenv("Version")) @@ -1601,7 +1601,7 @@ func ServeApi(job *engine.Job) error { return fmt.Errorf("usage: %s PROTO://ADDR [PROTO://ADDR ...]", job.Name) } go func() { - log.Infof("Listening for HTTP on %s (%s)", protoAddrParts[0], protoAddrParts[1]) + logrus.Infof("Listening for HTTP on %s (%s)", protoAddrParts[0], protoAddrParts[1]) srv, err := NewServer(protoAddrParts[0], protoAddrParts[1], job) if err != nil { chErrors <- err @@ -1609,7 +1609,7 @@ func ServeApi(job *engine.Job) error { } job.Eng.OnShutdown(func() { if err := srv.Close(); err != nil { - log.Error(err) + logrus.Error(err) } }) if err = srv.Serve(); err != nil && strings.Contains(err.Error(), "use of closed network connection") { diff --git a/builder/dispatchers.go b/builder/dispatchers.go index 4d21a75eb5e697c54da29cbfd8c769e26497e004..acb4d50de263523a9cbbb803bc8f517af14861f8 100644 --- a/builder/dispatchers.go +++ b/builder/dispatchers.go @@ -15,7 +15,7 @@ import ( "sort" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/nat" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/runconfig" @@ -264,7 +264,7 @@ func run(b *Builder, args []string, attributes map[string]bool, original string) defer func(cmd []string) { b.Config.Cmd = cmd }(cmd) - log.Debugf("[BUILDER] Command to be executed: %v", b.Config.Cmd) + logrus.Debugf("[BUILDER] Command to be executed: %v", b.Config.Cmd) hit, err := b.probeCache() if err != nil { diff --git a/builder/evaluator.go b/builder/evaluator.go index 78c4c12f846b65a6ae493f7996392089ec827328..6237f2663010a8e473cddd7f60af44857fff7f53 100644 --- a/builder/evaluator.go +++ b/builder/evaluator.go @@ -26,7 +26,7 @@ import ( "path/filepath" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/builder/command" "github.com/docker/docker/builder/parser" @@ -150,7 +150,7 @@ func (b *Builder) Run(context io.Reader) (string, error) { defer func() { if err := os.RemoveAll(b.contextPath); err != nil { - log.Debugf("[BUILDER] failed to remove temporary context: %s", err) + logrus.Debugf("[BUILDER] failed to remove temporary context: %s", err) } }() @@ -166,7 +166,7 @@ func (b *Builder) Run(context io.Reader) (string, error) { for i, n := range b.dockerfile.Children { select { case <-b.cancelled: - log.Debug("Builder: build cancelled!") + logrus.Debug("Builder: build cancelled!") fmt.Fprintf(b.OutStream, "Build cancelled") return "", fmt.Errorf("Build cancelled") default: diff --git a/builder/internals.go b/builder/internals.go index 1c90bf2d5e8d3501e1fda6d9eea701128c6194c4..f4f6a5575a85a33ebdffd70ef3f116c662a8c8c8 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -19,7 +19,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/builder/parser" "github.com/docker/docker/daemon" imagepkg "github.com/docker/docker/image" @@ -522,13 +522,13 @@ func (b *Builder) probeCache() (bool, error) { return false, err } if cache == nil { - log.Debugf("[BUILDER] Cache miss") + logrus.Debugf("[BUILDER] Cache miss") b.cacheBusted = true return false, nil } fmt.Fprintf(b.OutStream, " ---> Using cache\n") - log.Debugf("[BUILDER] Use cached version") + logrus.Debugf("[BUILDER] Use cached version") b.image = cache.ID return true, nil } @@ -587,7 +587,7 @@ func (b *Builder) run(c *daemon.Container) error { go func() { select { case <-b.cancelled: - log.Debugln("Build cancelled, killing container:", c.ID) + logrus.Debugln("Build cancelled, killing container:", c.ID) c.Kill() case <-finished: } @@ -688,7 +688,7 @@ func (b *Builder) addContext(container *daemon.Container, orig, dest string, dec if err := chrootarchive.UntarPath(origPath, tarDest); err == nil { return nil } else if err != io.EOF { - log.Debugf("Couldn't untar %s to %s: %s", origPath, tarDest, err) + logrus.Debugf("Couldn't untar %s to %s: %s", origPath, tarDest, err) } } diff --git a/contrib/docker-device-tool/device_tool.go b/contrib/docker-device-tool/device_tool.go index ffc34a54e092ab282ed3cfcafc1d49c770d745d5..9ad094a341a7799b23cf36d2bb4d88a136bda802 100644 --- a/contrib/docker-device-tool/device_tool.go +++ b/contrib/docker-device-tool/device_tool.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver/devmapper" "github.com/docker/docker/pkg/devicemapper" ) @@ -63,7 +63,7 @@ func main() { if *flDebug { os.Setenv("DEBUG", "1") - log.SetLevel(log.DebugLevel) + logrus.SetLevel(logrus.DebugLevel) } if flag.NArg() < 1 { diff --git a/daemon/attach.go b/daemon/attach.go index 24d67a7c6908c239682935319bcb3112f3019fb7..a479c040bed0cf4490376ad629271669cd11b221 100644 --- a/daemon/attach.go +++ b/daemon/attach.go @@ -8,7 +8,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/jsonlog" "github.com/docker/docker/pkg/promise" @@ -39,25 +39,25 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) error { cLog, err := container.ReadLog("json") if err != nil && os.IsNotExist(err) { // Legacy logs - log.Debugf("Old logs format") + logrus.Debugf("Old logs format") if stdout { cLog, err := container.ReadLog("stdout") if err != nil { - log.Errorf("Error reading logs (stdout): %s", err) + logrus.Errorf("Error reading logs (stdout): %s", err) } else if _, err := io.Copy(job.Stdout, cLog); err != nil { - log.Errorf("Error streaming logs (stdout): %s", err) + logrus.Errorf("Error streaming logs (stdout): %s", err) } } if stderr { cLog, err := container.ReadLog("stderr") if err != nil { - log.Errorf("Error reading logs (stderr): %s", err) + logrus.Errorf("Error reading logs (stderr): %s", err) } else if _, err := io.Copy(job.Stderr, cLog); err != nil { - log.Errorf("Error streaming logs (stderr): %s", err) + logrus.Errorf("Error streaming logs (stderr): %s", err) } } } else if err != nil { - log.Errorf("Error reading logs (json): %s", err) + logrus.Errorf("Error reading logs (json): %s", err) } else { dec := json.NewDecoder(cLog) for { @@ -66,7 +66,7 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) error { if err := dec.Decode(l); err == io.EOF { break } else if err != nil { - log.Errorf("Error streaming logs: %s", err) + logrus.Errorf("Error streaming logs: %s", err) break } if l.Stream == "stdout" && stdout { @@ -90,7 +90,7 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) error { r, w := io.Pipe() go func() { defer w.Close() - defer log.Debugf("Closing buffered stdin pipe") + defer logrus.Debugf("Closing buffered stdin pipe") io.Copy(w, job.Stdin) }() cStdin = r @@ -140,7 +140,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t if stdin == nil || !openStdin { return } - log.Debugf("attach: stdin: begin") + logrus.Debugf("attach: stdin: begin") defer func() { if stdinOnce && !tty { cStdin.Close() @@ -154,7 +154,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t } } wg.Done() - log.Debugf("attach: stdin: end") + logrus.Debugf("attach: stdin: end") }() var err error @@ -168,7 +168,7 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t err = nil } if err != nil { - log.Errorf("attach: stdin: %s", err) + logrus.Errorf("attach: stdin: %s", err) errors <- err return } @@ -185,16 +185,16 @@ func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, t } streamPipe.Close() wg.Done() - log.Debugf("attach: %s: end", name) + logrus.Debugf("attach: %s: end", name) }() - log.Debugf("attach: %s: begin", name) + logrus.Debugf("attach: %s: begin", name) _, err := io.Copy(stream, streamPipe) if err == io.ErrClosedPipe { err = nil } if err != nil { - log.Errorf("attach: %s: %v", name, err) + logrus.Errorf("attach: %s: %v", name, err) errors <- err } } diff --git a/daemon/container.go b/daemon/container.go index 3f16ab269142845ccbcc97f053820b486c0c75f5..ef8667369e889c7f791916bc9f8a4d0ddd005011 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -19,7 +19,7 @@ import ( "github.com/docker/libcontainer/devices" "github.com/docker/libcontainer/label" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/logger" "github.com/docker/docker/daemon/logger/jsonfilelog" @@ -201,7 +201,7 @@ func (container *Container) WriteHostConfig() error { func (container *Container) LogEvent(action string) { d := container.daemon if err := d.eng.Job("log", action, container.ID, d.Repositories().ImageName(container.ImageID)).Run(); err != nil { - log.Errorf("Error logging event %s for %s: %s", action, container.ID, err) + logrus.Errorf("Error logging event %s for %s: %s", action, container.ID, err) } } @@ -659,7 +659,7 @@ func (container *Container) cleanup() { } if err := container.Unmount(); err != nil { - log.Errorf("%v: Failed to umount filesystem: %v", container.ID, err) + logrus.Errorf("%v: Failed to umount filesystem: %v", container.ID, err) } for _, eConfig := range container.execCommands.s { @@ -668,7 +668,7 @@ func (container *Container) cleanup() { } func (container *Container) KillSig(sig int) error { - log.Debugf("Sending %d to %s", sig, container.ID) + logrus.Debugf("Sending %d to %s", sig, container.ID) container.Lock() defer container.Unlock() @@ -699,7 +699,7 @@ func (container *Container) KillSig(sig int) error { func (container *Container) killPossiblyDeadProcess(sig int) error { err := container.KillSig(sig) if err == syscall.ESRCH { - log.Debugf("Cannot kill process (pid=%d) with signal %d: no such process.", container.GetPid(), sig) + logrus.Debugf("Cannot kill process (pid=%d) with signal %d: no such process.", container.GetPid(), sig) return nil } return err @@ -739,12 +739,12 @@ func (container *Container) Kill() error { if _, err := container.WaitStop(10 * time.Second); err != nil { // Ensure that we don't kill ourselves if pid := container.GetPid(); pid != 0 { - log.Infof("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", stringid.TruncateID(container.ID)) + logrus.Infof("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", stringid.TruncateID(container.ID)) if err := syscall.Kill(pid, 9); err != nil { if err != syscall.ESRCH { return err } - log.Debugf("Cannot kill process (pid=%d) with signal 9: no such process.", pid) + logrus.Debugf("Cannot kill process (pid=%d) with signal 9: no such process.", pid) } } } @@ -760,7 +760,7 @@ func (container *Container) Stop(seconds int) error { // 1. Send a SIGTERM if err := container.killPossiblyDeadProcess(15); err != nil { - log.Infof("Failed to send SIGTERM to the process, force killing") + logrus.Infof("Failed to send SIGTERM to the process, force killing") if err := container.killPossiblyDeadProcess(9); err != nil { return err } @@ -768,7 +768,7 @@ func (container *Container) Stop(seconds int) error { // 2. Wait for the process to exit on its own if _, err := container.WaitStop(time.Duration(seconds) * time.Second); err != nil { - log.Infof("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds) + logrus.Infof("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds) // 3. If it doesn't, then send SIGKILL if err := container.Kill(); err != nil { container.WaitStop(-1 * time.Second) @@ -904,7 +904,7 @@ func (container *Container) GetSize() (int64, int64) { ) if err := container.Mount(); err != nil { - log.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err) + logrus.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err) return sizeRw, sizeRootfs } defer container.Unmount() @@ -912,7 +912,7 @@ func (container *Container) GetSize() (int64, int64) { initID := fmt.Sprintf("%s-init", container.ID) sizeRw, err = driver.DiffSize(container.ID, initID) if err != nil { - log.Errorf("Driver %s couldn't return diff size of container %s: %s", driver, container.ID, err) + logrus.Errorf("Driver %s couldn't return diff size of container %s: %s", driver, container.ID, err) // FIXME: GetSize should return an error. Not changing it now in case // there is a side-effect. sizeRw = -1 @@ -1007,7 +1007,7 @@ func (container *Container) DisableLink(name string) { if link, exists := container.activeLinks[name]; exists { link.Disable() } else { - log.Debugf("Could not find active link for %s", name) + logrus.Debugf("Could not find active link for %s", name) } } } @@ -1017,7 +1017,7 @@ func (container *Container) setupContainerDns() error { // check if this is an existing container that needs DNS update: if container.UpdateDns { // read the host's resolv.conf, get the hash and call updateResolvConf - log.Debugf("Check container (%s) for update to resolv.conf - UpdateDns flag was set", container.ID) + logrus.Debugf("Check container (%s) for update to resolv.conf - UpdateDns flag was set", container.ID) latestResolvConf, latestHash := resolvconf.GetLastModified() // clean container resolv.conf re: localhost nameservers and IPv6 NS (if IPv6 disabled) @@ -1133,7 +1133,7 @@ func (container *Container) updateResolvConf(updatedResolvConf []byte, newResolv //if the user has not modified the resolv.conf of the container since we wrote it last //we will replace it with the updated resolv.conf from the host if string(hashBytes) == curHash { - log.Debugf("replacing %q with updated host resolv.conf", container.ResolvConfPath) + logrus.Debugf("replacing %q with updated host resolv.conf", container.ResolvConfPath) // for atomic updates to these files, use temporary files with os.Rename: dir := path.Dir(container.ResolvConfPath) @@ -1172,13 +1172,13 @@ func (container *Container) updateParentsHosts() error { c, err := container.daemon.Get(ref.ParentID) if err != nil { - log.Error(err) + logrus.Error(err) } if c != nil && !container.daemon.config.DisableNetwork && container.hostConfig.NetworkMode.IsPrivate() { - log.Debugf("Update /etc/hosts of %s for alias %s with ip %s", c.ID, ref.Name, container.NetworkSettings.IPAddress) + logrus.Debugf("Update /etc/hosts of %s for alias %s with ip %s", c.ID, ref.Name, container.NetworkSettings.IPAddress) if err := etchosts.Update(c.HostsPath, container.NetworkSettings.IPAddress, ref.Name); err != nil { - log.Errorf("Failed to update /etc/hosts in parent container %s for alias %s: %v", c.ID, ref.Name, err) + logrus.Errorf("Failed to update /etc/hosts in parent container %s for alias %s: %v", c.ID, ref.Name, err) } } } @@ -1244,15 +1244,15 @@ func (container *Container) initializeNetworking() error { // Make sure the config is compatible with the current kernel func (container *Container) verifyDaemonSettings() { if container.Config.Memory > 0 && !container.daemon.sysInfo.MemoryLimit { - log.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.") + logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.") container.Config.Memory = 0 } if container.Config.Memory > 0 && !container.daemon.sysInfo.SwapLimit { - log.Warnf("Your kernel does not support swap limit capabilities. Limitation discarded.") + logrus.Warnf("Your kernel does not support swap limit capabilities. Limitation discarded.") container.Config.MemorySwap = -1 } if container.daemon.sysInfo.IPv4ForwardingDisabled { - log.Warnf("IPv4 forwarding is disabled. Networking will not work") + logrus.Warnf("IPv4 forwarding is disabled. Networking will not work") } } diff --git a/daemon/daemon.go b/daemon/daemon.go index eebf0a45f3bc1b2fcfb8f987381f09d6da2711a2..5e2f9c6b72ef8d1d74cd7e862417f8ef6818aa07 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -16,7 +16,7 @@ import ( "github.com/docker/libcontainer/label" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/daemon/execdriver" @@ -261,7 +261,7 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err // if so, then we need to restart monitor and init a new lock // If the container is supposed to be running, make sure of it if container.IsRunning() { - log.Debugf("killing old running container %s", container.ID) + logrus.Debugf("killing old running container %s", container.ID) existingPid := container.Pid container.SetStopped(&execdriver.ExitStatus{ExitCode: 0}) @@ -278,23 +278,23 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err var err error cmd.ProcessConfig.Process, err = os.FindProcess(existingPid) if err != nil { - log.Debugf("cannot find existing process for %d", existingPid) + logrus.Debugf("cannot find existing process for %d", existingPid) } daemon.execDriver.Terminate(cmd) } if err := container.Unmount(); err != nil { - log.Debugf("unmount error %s", err) + logrus.Debugf("unmount error %s", err) } if err := container.ToDisk(); err != nil { - log.Debugf("saving stopped state to disk %s", err) + logrus.Debugf("saving stopped state to disk %s", err) } info := daemon.execDriver.Info(container.ID) if !info.IsRunning() { - log.Debugf("Container %s was supposed to be running but is not.", container.ID) + logrus.Debugf("Container %s was supposed to be running but is not.", container.ID) - log.Debug("Marking as stopped") + logrus.Debug("Marking as stopped") container.SetStopped(&execdriver.ExitStatus{ExitCode: -127}) if err := container.ToDisk(); err != nil { @@ -314,7 +314,7 @@ func (daemon *Daemon) ensureName(container *Container) error { container.Name = name if err := container.ToDisk(); err != nil { - log.Debugf("Error saving container name %s", err) + logrus.Debugf("Error saving container name %s", err) } } return nil @@ -337,7 +337,7 @@ func (daemon *Daemon) restore() error { ) if !debug { - log.Info("Loading containers: start.") + logrus.Info("Loading containers: start.") } dir, err := ioutil.ReadDir(daemon.repository) if err != nil { @@ -347,21 +347,21 @@ func (daemon *Daemon) restore() error { for _, v := range dir { id := v.Name() container, err := daemon.load(id) - if !debug && log.GetLevel() == log.InfoLevel { + if !debug && logrus.GetLevel() == logrus.InfoLevel { fmt.Print(".") } if err != nil { - log.Errorf("Failed to load container %v: %v", id, err) + logrus.Errorf("Failed to load container %v: %v", id, err) continue } // Ignore the container if it does not support the current driver being used by the graph if (container.Driver == "" && currentDriver == "aufs") || container.Driver == currentDriver { - log.Debugf("Loaded container %v", container.ID) + logrus.Debugf("Loaded container %v", container.ID) containers[container.ID] = container } else { - log.Debugf("Cannot load container %s because it was created with another graph driver.", container.ID) + logrus.Debugf("Cannot load container %s because it was created with another graph driver.", container.ID) } } @@ -369,7 +369,7 @@ func (daemon *Daemon) restore() error { if entities := daemon.containerGraph.List("/", -1); entities != nil { for _, p := range entities.Paths() { - if !debug && log.GetLevel() == log.InfoLevel { + if !debug && logrus.GetLevel() == logrus.InfoLevel { fmt.Print(".") } @@ -377,7 +377,7 @@ func (daemon *Daemon) restore() error { if container, ok := containers[e.ID()]; ok { if err := daemon.register(container, false); err != nil { - log.Debugf("Failed to register container %s: %s", container.ID, err) + logrus.Debugf("Failed to register container %s: %s", container.ID, err) } registeredContainers = append(registeredContainers, container) @@ -393,11 +393,11 @@ func (daemon *Daemon) restore() error { // Try to set the default name for a container if it exists prior to links container.Name, err = daemon.generateNewName(container.ID) if err != nil { - log.Debugf("Setting default id - %s", err) + logrus.Debugf("Setting default id - %s", err) } if err := daemon.register(container, false); err != nil { - log.Debugf("Failed to register container %s: %s", container.ID, err) + logrus.Debugf("Failed to register container %s: %s", container.ID, err) } registeredContainers = append(registeredContainers, container) @@ -406,25 +406,25 @@ func (daemon *Daemon) restore() error { // check the restart policy on the containers and restart any container with // the restart policy of "always" if daemon.config.AutoRestart { - log.Debug("Restarting containers...") + logrus.Debug("Restarting containers...") for _, container := range registeredContainers { if container.hostConfig.RestartPolicy.Name == "always" || (container.hostConfig.RestartPolicy.Name == "on-failure" && container.ExitCode != 0) { - log.Debugf("Starting container %s", container.ID) + logrus.Debugf("Starting container %s", container.ID) if err := container.Start(); err != nil { - log.Debugf("Failed to start container %s: %s", container.ID, err) + logrus.Debugf("Failed to start container %s: %s", container.ID, err) } } } } if !debug { - if log.GetLevel() == log.InfoLevel { + if logrus.GetLevel() == logrus.InfoLevel { fmt.Println() } - log.Info("Loading containers: done.") + logrus.Info("Loading containers: done.") } return nil @@ -451,7 +451,7 @@ func (daemon *Daemon) setupResolvconfWatcher() error { // without an actual change to the file updatedResolvConf, newResolvConfHash, err := resolvconf.GetIfChanged() if err != nil { - log.Debugf("Error retrieving updated host resolv.conf: %v", err) + logrus.Debugf("Error retrieving updated host resolv.conf: %v", err) } else if updatedResolvConf != nil { // because the new host resolv.conf might have localhost nameservers.. updatedResolvConf, modified := resolvconf.FilterResolvDns(updatedResolvConf, daemon.config.EnableIPv6) @@ -459,22 +459,22 @@ func (daemon *Daemon) setupResolvconfWatcher() error { // changes have occurred during localhost cleanup: generate an updated hash newHash, err := utils.HashData(bytes.NewReader(updatedResolvConf)) if err != nil { - log.Debugf("Error generating hash of new resolv.conf: %v", err) + logrus.Debugf("Error generating hash of new resolv.conf: %v", err) } else { newResolvConfHash = newHash } } - log.Debug("host network resolv.conf changed--walking container list for updates") + logrus.Debug("host network resolv.conf changed--walking container list for updates") contList := daemon.containers.List() for _, container := range contList { if err := container.updateResolvConf(updatedResolvConf, newResolvConfHash); err != nil { - log.Debugf("Error on resolv.conf update check for container ID: %s: %v", container.ID, err) + logrus.Debugf("Error on resolv.conf update check for container ID: %s: %v", container.ID, err) } } } } case err := <-watcher.Errors: - log.Debugf("host resolv.conf notify error: %v", err) + logrus.Debugf("host resolv.conf notify error: %v", err) } } }() @@ -830,7 +830,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) // register portallocator release on shutdown eng.OnShutdown(func() { if err := portallocator.ReleaseAll(); err != nil { - log.Errorf("portallocator.ReleaseAll(): %s", err) + logrus.Errorf("portallocator.ReleaseAll(): %s", err) } }) // Claim the pidfile first, to avoid any and all unexpected race conditions. @@ -892,11 +892,11 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) if err != nil { return nil, fmt.Errorf("error intializing graphdriver: %v", err) } - log.Debugf("Using graph driver %s", driver) + logrus.Debugf("Using graph driver %s", driver) // register cleanup for graph driver eng.OnShutdown(func() { if err := driver.Cleanup(); err != nil { - log.Errorf("Error during graph storage driver.Cleanup(): %v", err) + logrus.Errorf("Error during graph storage driver.Cleanup(): %v", err) } }) @@ -906,9 +906,9 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) if driver.String() == "btrfs" { return nil, fmt.Errorf("SELinux is not supported with the BTRFS graph driver") } - log.Debug("SELinux enabled successfully") + logrus.Debug("SELinux enabled successfully") } else { - log.Warn("Docker could not enable SELinux on the host system") + logrus.Warn("Docker could not enable SELinux on the host system") } } else { selinuxSetDisabled() @@ -925,7 +925,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) return nil, err } - log.Debug("Creating images graph") + logrus.Debug("Creating images graph") g, err := graph.NewGraph(path.Join(config.Root, "graph"), driver) if err != nil { return nil, err @@ -946,7 +946,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) return nil, err } - log.Debug("Creating repository list") + logrus.Debug("Creating repository list") repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g, trustKey) if err != nil { return nil, fmt.Errorf("Couldn't create Tag store: %s", err) @@ -988,7 +988,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) // register graph close on shutdown eng.OnShutdown(func() { if err := graph.Close(); err != nil { - log.Errorf("Error during container graph.Close(): %v", err) + logrus.Errorf("Error during container graph.Close(): %v", err) } }) @@ -1042,7 +1042,7 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) eng.OnShutdown(func() { if err := daemon.shutdown(); err != nil { - log.Errorf("Error during daemon.shutdown(): %v", err) + logrus.Errorf("Error during daemon.shutdown(): %v", err) } }) @@ -1060,20 +1060,20 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) func (daemon *Daemon) shutdown() error { group := sync.WaitGroup{} - log.Debug("starting clean shutdown of all containers...") + logrus.Debug("starting clean shutdown of all containers...") for _, container := range daemon.List() { c := container if c.IsRunning() { - log.Debugf("stopping %s", c.ID) + logrus.Debugf("stopping %s", c.ID) group.Add(1) go func() { defer group.Done() if err := c.KillSig(15); err != nil { - log.Debugf("kill 15 error for %s - %s", c.ID, err) + logrus.Debugf("kill 15 error for %s - %s", c.ID, err) } c.WaitStop(-1 * time.Second) - log.Debugf("container stopped %s", c.ID) + logrus.Debugf("container stopped %s", c.ID) }() } } @@ -1255,11 +1255,11 @@ func checkKernel() error { // the circumstances of pre-3.8 crashes are clearer. // For details see http://github.com/docker/docker/issues/407 if k, err := kernel.GetKernelVersion(); err != nil { - log.Warnf("%s", err) + logrus.Warnf("%s", err) } else { if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 { if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" { - log.Warnf("You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.8.0.", k.String()) + logrus.Warnf("You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.8.0.", k.String()) } } } diff --git a/daemon/daemon_aufs.go b/daemon/daemon_aufs.go index 7d4d3c32e9ddc64fe661dd64bf5127f44927f700..377e829793cb5830c03154ec9f5a8d4909b585d7 100644 --- a/daemon/daemon_aufs.go +++ b/daemon/daemon_aufs.go @@ -3,7 +3,7 @@ package daemon import ( - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/aufs" "github.com/docker/docker/graph" @@ -13,7 +13,7 @@ import ( // If aufs driver is not built, this func is a noop. func migrateIfAufs(driver graphdriver.Driver, root string) error { if ad, ok := driver.(*aufs.Driver); ok { - log.Debugf("Migrating existing containers") + logrus.Debugf("Migrating existing containers") if err := ad.Migrate(root, graph.SetupInitLayer); err != nil { return err } diff --git a/daemon/delete.go b/daemon/delete.go index 9f31d6d5523af87d4c0106194754885475a6e924..3127181967f908113c860531ccde7b23c3b11ec8 100644 --- a/daemon/delete.go +++ b/daemon/delete.go @@ -5,7 +5,7 @@ import ( "os" "path" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" ) @@ -77,7 +77,7 @@ func (daemon *Daemon) ContainerRm(job *engine.Job) error { func (daemon *Daemon) DeleteVolumes(volumeIDs map[string]struct{}) { for id := range volumeIDs { if err := daemon.volumes.Delete(id); err != nil { - log.Infof("%s", err) + logrus.Infof("%s", err) continue } } @@ -103,7 +103,7 @@ func (daemon *Daemon) Rm(container *Container) error { daemon.containers.Delete(container.ID) container.derefVolumes() if _, err := daemon.containerGraph.Purge(container.ID); err != nil { - log.Debugf("Unable to remove container from link graph: %s", err) + logrus.Debugf("Unable to remove container from link graph: %s", err) } if err := daemon.driver.Remove(container.ID); err != nil { diff --git a/daemon/exec.go b/daemon/exec.go index c7d494bb06c708b3af100bb2bd608a732c37dbae..c5d44617652c74d84f92773ee2ac8dfe9c9e946f 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/execdriver/lxc" "github.com/docker/docker/engine" @@ -188,7 +188,7 @@ func (d *Daemon) ContainerExecStart(job *engine.Job) error { return err } - log.Debugf("starting exec command %s in container %s", execConfig.ID, execConfig.Container.ID) + logrus.Debugf("starting exec command %s in container %s", execConfig.ID, execConfig.Container.ID) container := execConfig.Container container.LogEvent("exec_start: " + execConfig.ProcessConfig.Entrypoint + " " + strings.Join(execConfig.ProcessConfig.Arguments, " ")) @@ -197,7 +197,7 @@ func (d *Daemon) ContainerExecStart(job *engine.Job) error { r, w := io.Pipe() go func() { defer w.Close() - defer log.Debugf("Closing buffered stdin pipe") + defer logrus.Debugf("Closing buffered stdin pipe") io.Copy(w, job.Stdin) }() cStdin = r @@ -305,24 +305,24 @@ func (container *Container) monitorExec(execConfig *execConfig, callback execdri pipes := execdriver.NewPipes(execConfig.StreamConfig.stdin, execConfig.StreamConfig.stdout, execConfig.StreamConfig.stderr, execConfig.OpenStdin) exitCode, err = container.daemon.Exec(container, execConfig, pipes, callback) if err != nil { - log.Errorf("Error running command in existing container %s: %s", container.ID, err) + logrus.Errorf("Error running command in existing container %s: %s", container.ID, err) } - log.Debugf("Exec task in container %s exited with code %d", container.ID, exitCode) + logrus.Debugf("Exec task in container %s exited with code %d", container.ID, exitCode) if execConfig.OpenStdin { if err := execConfig.StreamConfig.stdin.Close(); err != nil { - log.Errorf("Error closing stdin while running in %s: %s", container.ID, err) + logrus.Errorf("Error closing stdin while running in %s: %s", container.ID, err) } } if err := execConfig.StreamConfig.stdout.Clean(); err != nil { - log.Errorf("Error closing stdout while running in %s: %s", container.ID, err) + logrus.Errorf("Error closing stdout while running in %s: %s", container.ID, err) } if err := execConfig.StreamConfig.stderr.Clean(); err != nil { - log.Errorf("Error closing stderr while running in %s: %s", container.ID, err) + logrus.Errorf("Error closing stderr while running in %s: %s", container.ID, err) } if execConfig.ProcessConfig.Terminal != nil { if err := execConfig.ProcessConfig.Terminal.Close(); err != nil { - log.Errorf("Error closing terminal while running in container %s: %s", container.ID, err) + logrus.Errorf("Error closing terminal while running in container %s: %s", container.ID, err) } } diff --git a/daemon/execdriver/lxc/driver.go b/daemon/execdriver/lxc/driver.go index 55c4ac4e141f5564a45af14254c87339284afd8a..97b34bb6785861890e23f6f7b6f9480f25b0945e 100644 --- a/daemon/execdriver/lxc/driver.go +++ b/daemon/execdriver/lxc/driver.go @@ -16,7 +16,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" sysinfo "github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/term" @@ -193,7 +193,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba "unshare", "-m", "--", "/bin/sh", "-c", shellString, } } - log.Debugf("lxc params %s", params) + logrus.Debugf("lxc params %s", params) var ( name = params[0] arg = params[1:] @@ -263,7 +263,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba c.ContainerPid = pid if startCallback != nil { - log.Debugf("Invoking startCallback") + logrus.Debugf("Invoking startCallback") startCallback(&c.ProcessConfig, pid) } @@ -274,9 +274,9 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba if err == nil { _, oomKill = <-oomKillNotification - log.Debugf("oomKill error %s waitErr %s", oomKill, waitErr) + logrus.Debugf("oomKill error %s waitErr %s", oomKill, waitErr) } else { - log.Warnf("Your kernel does not support OOM notifications: %s", err) + logrus.Warnf("Your kernel does not support OOM notifications: %s", err) } // check oom error @@ -351,11 +351,11 @@ func cgroupPaths(containerId string) (map[string]string, error) { if err != nil { return nil, err } - log.Debugf("subsystems: %s", subsystems) + logrus.Debugf("subsystems: %s", subsystems) paths := make(map[string]string) for _, subsystem := range subsystems { cgroupRoot, cgroupDir, err := findCgroupRootAndDir(subsystem) - log.Debugf("cgroup path %s %s", cgroupRoot, cgroupDir) + logrus.Debugf("cgroup path %s %s", cgroupRoot, cgroupDir) if err != nil { //unsupported subystem continue @@ -576,7 +576,7 @@ func (i *info) IsRunning() bool { output, err := i.driver.getInfo(i.ID) if err != nil { - log.Errorf("Error getting info for lxc container %s: %s (%s)", i.ID, err, output) + logrus.Errorf("Error getting info for lxc container %s: %s (%s)", i.ID, err, output) return false } if strings.Contains(string(output), "RUNNING") { diff --git a/daemon/execdriver/lxc/lxc_template.go b/daemon/execdriver/lxc/lxc_template.go index e4a8ed6b5f8cac02ff125f266df73b813a0faac1..02313d465ad59b1e2a22007f0b8b26030c258036 100644 --- a/daemon/execdriver/lxc/lxc_template.go +++ b/daemon/execdriver/lxc/lxc_template.go @@ -6,7 +6,7 @@ import ( "strings" "text/template" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" nativeTemplate "github.com/docker/docker/daemon/execdriver/native/template" "github.com/docker/docker/utils" @@ -160,14 +160,14 @@ func escapeFstabSpaces(field string) string { func keepCapabilities(adds []string, drops []string) ([]string, error) { container := nativeTemplate.New() - log.Debugf("adds %s drops %s\n", adds, drops) + logrus.Debugf("adds %s drops %s\n", adds, drops) caps, err := execdriver.TweakCapabilities(container.Capabilities, adds, drops) if err != nil { return nil, err } var newCaps []string for _, cap := range caps { - log.Debugf("cap %s\n", cap) + logrus.Debugf("cap %s\n", cap) realCap := execdriver.GetCapability(cap) numCap := fmt.Sprintf("%d", realCap.Value) newCaps = append(newCaps, numCap) @@ -181,7 +181,7 @@ func dropList(drops []string) ([]string, error) { var newCaps []string for _, capName := range execdriver.GetAllCapabilities() { cap := execdriver.GetCapability(capName) - log.Debugf("drop cap %s\n", cap.Key) + logrus.Debugf("drop cap %s\n", cap.Key) numCap := fmt.Sprintf("%d", cap.Value) newCaps = append(newCaps, numCap) } @@ -192,7 +192,7 @@ func dropList(drops []string) ([]string, error) { func isDirectory(source string) string { f, err := os.Stat(source) - log.Debugf("dir: %s\n", source) + logrus.Debugf("dir: %s\n", source) if err != nil { if os.IsNotExist(err) { return "dir" diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index 46097a8cc59d2e190449eec258da02761cebce3a..030c3b546497a44eb54ceef96533a66c0f443bea 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -15,7 +15,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/pkg/reexec" sysinfo "github.com/docker/docker/pkg/system" @@ -159,7 +159,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba oomKillNotification, err := cont.NotifyOOM() if err != nil { oomKillNotification = nil - log.Warnf("Your kernel does not support OOM notifications: %s", err) + logrus.Warnf("Your kernel does not support OOM notifications: %s", err) } waitF := p.Wait if nss := cont.Config().Namespaces; nss.Contains(configs.NEWPID) { @@ -206,7 +206,7 @@ func waitInPIDHost(p *libcontainer.Process, c libcontainer.Container) func() (*o for _, pid := range processes { process, err := os.FindProcess(pid) if err != nil { - log.Errorf("Failed to kill process: %d", pid) + logrus.Errorf("Failed to kill process: %d", pid) continue } process.Kill() diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index bc4b5c08164351eb1f6151cc896ff1c5d1a839c3..5c8662488b3476188cbb68e42a6236c4b3c73c08 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -30,7 +30,7 @@ import ( "sync" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" @@ -216,7 +216,7 @@ func (a *Driver) Remove(id string) error { defer a.Unlock() if a.active[id] != 0 { - log.Errorf("Removing active id %s", id) + logrus.Errorf("Removing active id %s", id) } // Make sure the dir is umounted first @@ -405,7 +405,7 @@ func (a *Driver) Cleanup() error { for _, id := range ids { if err := a.unmount(id); err != nil { - log.Errorf("Unmounting %s: %s", stringid.TruncateID(id), err) + logrus.Errorf("Unmounting %s: %s", stringid.TruncateID(id), err) } } diff --git a/daemon/graphdriver/aufs/mount.go b/daemon/graphdriver/aufs/mount.go index a3a5a86595c8409bda3a6302687e873e136edc9b..0a3d9d16a0746449a0df8258c7aeb60cb97f82e4 100644 --- a/daemon/graphdriver/aufs/mount.go +++ b/daemon/graphdriver/aufs/mount.go @@ -4,12 +4,12 @@ import ( "os/exec" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) func Unmount(target string) error { if err := exec.Command("auplink", target, "flush").Run(); err != nil { - log.Errorf("Couldn't run auplink before unmount: %s", err) + logrus.Errorf("Couldn't run auplink before unmount: %s", err) } if err := syscall.Unmount(target, 0); err != nil { return err diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index 98980cc8817cf0a1ef978c5446b1add0dc3e9ebf..4d35adabc04f121d1604352ca831b1d34eab042b 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -18,7 +18,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/devicemapper" "github.com/docker/docker/pkg/parsers" @@ -205,7 +205,7 @@ func (devices *DeviceSet) ensureImage(name string, size int64) (string, error) { if !os.IsNotExist(err) { return "", err } - log.Debugf("Creating loopback file %s for device-manage use", filename) + logrus.Debugf("Creating loopback file %s for device-manage use", filename) file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0600) if err != nil { return "", err @@ -320,21 +320,21 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo) // Skip some of the meta files which are not device files. if strings.HasSuffix(finfo.Name(), ".migrated") { - log.Debugf("Skipping file %s", path) + logrus.Debugf("Skipping file %s", path) return nil } if strings.HasPrefix(finfo.Name(), ".") { - log.Debugf("Skipping file %s", path) + logrus.Debugf("Skipping file %s", path) return nil } if finfo.Name() == deviceSetMetaFile { - log.Debugf("Skipping file %s", path) + logrus.Debugf("Skipping file %s", path) return nil } - log.Debugf("Loading data for file %s", path) + logrus.Debugf("Loading data for file %s", path) hash := finfo.Name() if hash == "base" { @@ -347,7 +347,7 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo) } if dinfo.DeviceId > MaxDeviceId { - log.Errorf("Ignoring Invalid DeviceId=%d", dinfo.DeviceId) + logrus.Errorf("Ignoring Invalid DeviceId=%d", dinfo.DeviceId) return nil } @@ -355,17 +355,17 @@ func (devices *DeviceSet) deviceFileWalkFunction(path string, finfo os.FileInfo) devices.markDeviceIdUsed(dinfo.DeviceId) devices.Unlock() - log.Debugf("Added deviceId=%d to DeviceIdMap", dinfo.DeviceId) + logrus.Debugf("Added deviceId=%d to DeviceIdMap", dinfo.DeviceId) return nil } func (devices *DeviceSet) constructDeviceIdMap() error { - log.Debugf("[deviceset] constructDeviceIdMap()") - defer log.Debugf("[deviceset] constructDeviceIdMap() END") + logrus.Debugf("[deviceset] constructDeviceIdMap()") + defer logrus.Debugf("[deviceset] constructDeviceIdMap() END") var scan = func(path string, info os.FileInfo, err error) error { if err != nil { - log.Debugf("Can't walk the file %s", path) + logrus.Debugf("Can't walk the file %s", path) return nil } @@ -381,7 +381,7 @@ func (devices *DeviceSet) constructDeviceIdMap() error { } func (devices *DeviceSet) unregisterDevice(id int, hash string) error { - log.Debugf("unregisterDevice(%v, %v)", id, hash) + logrus.Debugf("unregisterDevice(%v, %v)", id, hash) info := &DevInfo{ Hash: hash, DeviceId: id, @@ -392,7 +392,7 @@ func (devices *DeviceSet) unregisterDevice(id int, hash string) error { devices.devicesLock.Unlock() if err := devices.removeMetadata(info); err != nil { - log.Debugf("Error removing metadata: %s", err) + logrus.Debugf("Error removing metadata: %s", err) return err } @@ -400,7 +400,7 @@ func (devices *DeviceSet) unregisterDevice(id int, hash string) error { } func (devices *DeviceSet) registerDevice(id int, hash string, size uint64, transactionId uint64) (*DevInfo, error) { - log.Debugf("registerDevice(%v, %v)", id, hash) + logrus.Debugf("registerDevice(%v, %v)", id, hash) info := &DevInfo{ Hash: hash, DeviceId: id, @@ -426,7 +426,7 @@ func (devices *DeviceSet) registerDevice(id int, hash string, size uint64, trans } func (devices *DeviceSet) activateDeviceIfNeeded(info *DevInfo) error { - log.Debugf("activateDeviceIfNeeded(%v)", info.Hash) + logrus.Debugf("activateDeviceIfNeeded(%v)", info.Hash) if devinfo, _ := devicemapper.GetInfo(info.Name()); devinfo != nil && devinfo.Exists != 0 { return nil @@ -542,7 +542,7 @@ func (devices *DeviceSet) createRegisterDevice(hash string) (*DevInfo, error) { } if err := devices.openTransaction(hash, deviceId); err != nil { - log.Debugf("Error opening transaction hash = %s deviceId = %d", hash, deviceId) + logrus.Debugf("Error opening transaction hash = %s deviceId = %d", hash, deviceId) devices.markDeviceIdFree(deviceId) return nil, err } @@ -554,7 +554,7 @@ func (devices *DeviceSet) createRegisterDevice(hash string) (*DevInfo, error) { // happen. Now we have a mechianism to find // a free device Id. So something is not right. // Give a warning and continue. - log.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId) + logrus.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId) deviceId, err = devices.getNextFreeDeviceId() if err != nil { return nil, err @@ -563,14 +563,14 @@ func (devices *DeviceSet) createRegisterDevice(hash string) (*DevInfo, error) { devices.refreshTransaction(deviceId) continue } - log.Debugf("Error creating device: %s", err) + logrus.Debugf("Error creating device: %s", err) devices.markDeviceIdFree(deviceId) return nil, err } break } - log.Debugf("Registering device (id %v) with FS size %v", deviceId, devices.baseFsSize) + logrus.Debugf("Registering device (id %v) with FS size %v", deviceId, devices.baseFsSize) info, err := devices.registerDevice(deviceId, hash, devices.baseFsSize, devices.OpenTransactionId) if err != nil { _ = devicemapper.DeleteDevice(devices.getPoolDevName(), deviceId) @@ -594,7 +594,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf } if err := devices.openTransaction(hash, deviceId); err != nil { - log.Debugf("Error opening transaction hash = %s deviceId = %d", hash, deviceId) + logrus.Debugf("Error opening transaction hash = %s deviceId = %d", hash, deviceId) devices.markDeviceIdFree(deviceId) return err } @@ -606,7 +606,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf // happen. Now we have a mechianism to find // a free device Id. So something is not right. // Give a warning and continue. - log.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId) + logrus.Errorf("Device Id %d exists in pool but it is supposed to be unused", deviceId) deviceId, err = devices.getNextFreeDeviceId() if err != nil { return err @@ -615,7 +615,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf devices.refreshTransaction(deviceId) continue } - log.Debugf("Error creating snap device: %s", err) + logrus.Debugf("Error creating snap device: %s", err) devices.markDeviceIdFree(deviceId) return err } @@ -625,7 +625,7 @@ func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *DevInf if _, err := devices.registerDevice(deviceId, hash, baseInfo.Size, devices.OpenTransactionId); err != nil { devicemapper.DeleteDevice(devices.getPoolDevName(), deviceId) devices.markDeviceIdFree(deviceId) - log.Debugf("Error registering device: %s", err) + logrus.Debugf("Error registering device: %s", err) return err } @@ -660,7 +660,7 @@ func (devices *DeviceSet) setupBaseImage() error { } if oldInfo != nil && !oldInfo.Initialized { - log.Debugf("Removing uninitialized base image") + logrus.Debugf("Removing uninitialized base image") if err := devices.DeleteDevice(""); err != nil { return err } @@ -681,7 +681,7 @@ func (devices *DeviceSet) setupBaseImage() error { } } - log.Debugf("Initializing base device-mapper thin volume") + logrus.Debugf("Initializing base device-mapper thin volume") // Create initial device info, err := devices.createRegisterDevice("") @@ -689,7 +689,7 @@ func (devices *DeviceSet) setupBaseImage() error { return err } - log.Debugf("Creating filesystem on base device-mapper thin volume") + logrus.Debugf("Creating filesystem on base device-mapper thin volume") if err = devices.activateDeviceIfNeeded(info); err != nil { return err @@ -730,7 +730,7 @@ func (devices *DeviceSet) DMLog(level int, file string, line int, dmError int, m } // FIXME(vbatts) push this back into ./pkg/devicemapper/ - log.Debugf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message) + logrus.Debugf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message) } func major(device uint64) uint64 { @@ -846,24 +846,24 @@ func (devices *DeviceSet) removeTransactionMetaData() error { } func (devices *DeviceSet) rollbackTransaction() error { - log.Debugf("Rolling back open transaction: TransactionId=%d hash=%s device_id=%d", devices.OpenTransactionId, devices.DeviceIdHash, devices.DeviceId) + logrus.Debugf("Rolling back open transaction: TransactionId=%d hash=%s device_id=%d", devices.OpenTransactionId, devices.DeviceIdHash, devices.DeviceId) // A device id might have already been deleted before transaction // closed. In that case this call will fail. Just leave a message // in case of failure. if err := devicemapper.DeleteDevice(devices.getPoolDevName(), devices.DeviceId); err != nil { - log.Errorf("Unable to delete device: %s", err) + logrus.Errorf("Unable to delete device: %s", err) } dinfo := &DevInfo{Hash: devices.DeviceIdHash} if err := devices.removeMetadata(dinfo); err != nil { - log.Errorf("Unable to remove metadata: %s", err) + logrus.Errorf("Unable to remove metadata: %s", err) } else { devices.markDeviceIdFree(devices.DeviceId) } if err := devices.removeTransactionMetaData(); err != nil { - log.Errorf("Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err) + logrus.Errorf("Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err) } return nil @@ -883,7 +883,7 @@ func (devices *DeviceSet) processPendingTransaction() error { // If open transaction Id is less than pool transaction Id, something // is wrong. Bail out. if devices.OpenTransactionId < devices.TransactionId { - log.Errorf("Open Transaction id %d is less than pool transaction id %d", devices.OpenTransactionId, devices.TransactionId) + logrus.Errorf("Open Transaction id %d is less than pool transaction id %d", devices.OpenTransactionId, devices.TransactionId) return nil } @@ -940,7 +940,7 @@ func (devices *DeviceSet) refreshTransaction(DeviceId int) error { func (devices *DeviceSet) closeTransaction() error { if err := devices.updatePoolTransactionId(); err != nil { - log.Debugf("Failed to close Transaction") + logrus.Debugf("Failed to close Transaction") return err } return nil @@ -963,9 +963,9 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { // https://github.com/docker/docker/issues/4036 if supported := devicemapper.UdevSetSyncSupport(true); !supported { - log.Warnf("Udev sync is not supported. This will lead to unexpected behavior, data loss and errors") + logrus.Warnf("Udev sync is not supported. This will lead to unexpected behavior, data loss and errors") } - log.Debugf("devicemapper: udev sync support: %v", devicemapper.UdevSyncSupported()) + logrus.Debugf("devicemapper: udev sync support: %v", devicemapper.UdevSyncSupported()) if err := os.MkdirAll(devices.metadataDir(), 0700); err != nil && !os.IsExist(err) { return err @@ -985,13 +985,13 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { // - The target of this device is at major and minor // - If is defined, use that file inside the device as a loopback image. Otherwise use the device itself. devices.devicePrefix = fmt.Sprintf("docker-%d:%d-%d", major(sysSt.Dev), minor(sysSt.Dev), sysSt.Ino) - log.Debugf("Generated prefix: %s", devices.devicePrefix) + logrus.Debugf("Generated prefix: %s", devices.devicePrefix) // Check for the existence of the thin-pool device - log.Debugf("Checking for existence of the pool '%s'", devices.getPoolName()) + logrus.Debugf("Checking for existence of the pool '%s'", devices.getPoolName()) info, err := devicemapper.GetInfo(devices.getPoolName()) if info == nil { - log.Debugf("Error device devicemapper.GetInfo: %s", err) + logrus.Debugf("Error device devicemapper.GetInfo: %s", err) return err } @@ -1007,7 +1007,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { // If the pool doesn't exist, create it if info.Exists == 0 && devices.thinPoolDevice == "" { - log.Debugf("Pool doesn't exist. Creating it.") + logrus.Debugf("Pool doesn't exist. Creating it.") var ( dataFile *os.File @@ -1029,7 +1029,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { data, err := devices.ensureImage("data", devices.dataLoopbackSize) if err != nil { - log.Debugf("Error device ensureImage (data): %s", err) + logrus.Debugf("Error device ensureImage (data): %s", err) return err } @@ -1062,7 +1062,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { metadata, err := devices.ensureImage("metadata", devices.metaDataLoopbackSize) if err != nil { - log.Debugf("Error device ensureImage (metadata): %s", err) + logrus.Debugf("Error device ensureImage (metadata): %s", err) return err } @@ -1102,7 +1102,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { // Setup the base image if doInit { if err := devices.setupBaseImage(); err != nil { - log.Debugf("Error device setupBaseImage: %s", err) + logrus.Debugf("Error device setupBaseImage: %s", err) return err } } @@ -1111,8 +1111,8 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error { } func (devices *DeviceSet) AddDevice(hash, baseHash string) error { - log.Debugf("[deviceset] AddDevice(hash=%s basehash=%s)", hash, baseHash) - defer log.Debugf("[deviceset] AddDevice(hash=%s basehash=%s) END", hash, baseHash) + logrus.Debugf("[deviceset] AddDevice(hash=%s basehash=%s)", hash, baseHash) + defer logrus.Debugf("[deviceset] AddDevice(hash=%s basehash=%s) END", hash, baseHash) baseInfo, err := devices.lookupDevice(baseHash) if err != nil { @@ -1143,7 +1143,7 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error { // manually if err := devices.activateDeviceIfNeeded(info); err == nil { if err := devicemapper.BlockDeviceDiscard(info.DevName()); err != nil { - log.Debugf("Error discarding block on device: %s (ignoring)", err) + logrus.Debugf("Error discarding block on device: %s (ignoring)", err) } } } @@ -1151,18 +1151,18 @@ func (devices *DeviceSet) deleteDevice(info *DevInfo) error { devinfo, _ := devicemapper.GetInfo(info.Name()) if devinfo != nil && devinfo.Exists != 0 { if err := devices.removeDeviceAndWait(info.Name()); err != nil { - log.Debugf("Error removing device: %s", err) + logrus.Debugf("Error removing device: %s", err) return err } } if err := devices.openTransaction(info.Hash, info.DeviceId); err != nil { - log.Debugf("Error opening transaction hash = %s deviceId = %d", "", info.DeviceId) + logrus.Debugf("Error opening transaction hash = %s deviceId = %d", "", info.DeviceId) return err } if err := devicemapper.DeleteDevice(devices.getPoolDevName(), info.DeviceId); err != nil { - log.Debugf("Error deleting device: %s", err) + logrus.Debugf("Error deleting device: %s", err) return err } @@ -1195,8 +1195,8 @@ func (devices *DeviceSet) DeleteDevice(hash string) error { } func (devices *DeviceSet) deactivatePool() error { - log.Debugf("[devmapper] deactivatePool()") - defer log.Debugf("[devmapper] deactivatePool END") + logrus.Debugf("[devmapper] deactivatePool()") + defer logrus.Debugf("[devmapper] deactivatePool END") devname := devices.getPoolDevName() devinfo, err := devicemapper.GetInfo(devname) @@ -1205,7 +1205,7 @@ func (devices *DeviceSet) deactivatePool() error { } if d, err := devicemapper.GetDeps(devname); err == nil { // Access to more Debug output - log.Debugf("[devmapper] devicemapper.GetDeps() %s: %#v", devname, d) + logrus.Debugf("[devmapper] devicemapper.GetDeps() %s: %#v", devname, d) } if devinfo.Exists != 0 { return devicemapper.RemoveDevice(devname) @@ -1215,13 +1215,13 @@ func (devices *DeviceSet) deactivatePool() error { } func (devices *DeviceSet) deactivateDevice(info *DevInfo) error { - log.Debugf("[devmapper] deactivateDevice(%s)", info.Hash) - defer log.Debugf("[devmapper] deactivateDevice END(%s)", info.Hash) + logrus.Debugf("[devmapper] deactivateDevice(%s)", info.Hash) + defer logrus.Debugf("[devmapper] deactivateDevice END(%s)", info.Hash) // Wait for the unmount to be effective, // by watching the value of Info.OpenCount for the device if err := devices.waitClose(info); err != nil { - log.Errorf("Error waiting for device %s to close: %s", info.Hash, err) + logrus.Errorf("Error waiting for device %s to close: %s", info.Hash, err) } devinfo, err := devicemapper.GetInfo(info.Name()) @@ -1271,8 +1271,8 @@ func (devices *DeviceSet) removeDeviceAndWait(devname string) error { // a) the device registered at - is removed, // or b) the 10 second timeout expires. func (devices *DeviceSet) waitRemove(devname string) error { - log.Debugf("[deviceset %s] waitRemove(%s)", devices.devicePrefix, devname) - defer log.Debugf("[deviceset %s] waitRemove(%s) END", devices.devicePrefix, devname) + logrus.Debugf("[deviceset %s] waitRemove(%s)", devices.devicePrefix, devname) + defer logrus.Debugf("[deviceset %s] waitRemove(%s) END", devices.devicePrefix, devname) i := 0 for ; i < 1000; i++ { devinfo, err := devicemapper.GetInfo(devname) @@ -1282,7 +1282,7 @@ func (devices *DeviceSet) waitRemove(devname string) error { return nil } if i%100 == 0 { - log.Debugf("Waiting for removal of %s: exists=%d", devname, devinfo.Exists) + logrus.Debugf("Waiting for removal of %s: exists=%d", devname, devinfo.Exists) } if devinfo.Exists == 0 { break @@ -1309,7 +1309,7 @@ func (devices *DeviceSet) waitClose(info *DevInfo) error { return err } if i%100 == 0 { - log.Debugf("Waiting for unmount of %s: opencount=%d", info.Hash, devinfo.OpenCount) + logrus.Debugf("Waiting for unmount of %s: opencount=%d", info.Hash, devinfo.OpenCount) } if devinfo.OpenCount == 0 { break @@ -1325,9 +1325,9 @@ func (devices *DeviceSet) waitClose(info *DevInfo) error { } func (devices *DeviceSet) Shutdown() error { - log.Debugf("[deviceset %s] Shutdown()", devices.devicePrefix) - log.Debugf("[devmapper] Shutting down DeviceSet: %s", devices.root) - defer log.Debugf("[deviceset %s] Shutdown() END", devices.devicePrefix) + logrus.Debugf("[deviceset %s] Shutdown()", devices.devicePrefix) + logrus.Debugf("[devmapper] Shutting down DeviceSet: %s", devices.root) + defer logrus.Debugf("[deviceset %s] Shutdown() END", devices.devicePrefix) var devs []*DevInfo @@ -1344,12 +1344,12 @@ func (devices *DeviceSet) Shutdown() error { // container. This means it'll go away from the global scope directly, // and the device will be released when that container dies. if err := syscall.Unmount(info.mountPath, syscall.MNT_DETACH); err != nil { - log.Debugf("Shutdown unmounting %s, error: %s", info.mountPath, err) + logrus.Debugf("Shutdown unmounting %s, error: %s", info.mountPath, err) } devices.Lock() if err := devices.deactivateDevice(info); err != nil { - log.Debugf("Shutdown deactivate %s , error: %s", info.Hash, err) + logrus.Debugf("Shutdown deactivate %s , error: %s", info.Hash, err) } devices.Unlock() } @@ -1361,7 +1361,7 @@ func (devices *DeviceSet) Shutdown() error { info.lock.Lock() devices.Lock() if err := devices.deactivateDevice(info); err != nil { - log.Debugf("Shutdown deactivate base , error: %s", err) + logrus.Debugf("Shutdown deactivate base , error: %s", err) } devices.Unlock() info.lock.Unlock() @@ -1370,7 +1370,7 @@ func (devices *DeviceSet) Shutdown() error { devices.Lock() if devices.thinPoolDevice == "" { if err := devices.deactivatePool(); err != nil { - log.Debugf("Shutdown deactivate pool , error: %s", err) + logrus.Debugf("Shutdown deactivate pool , error: %s", err) } } @@ -1437,8 +1437,8 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error { } func (devices *DeviceSet) UnmountDevice(hash string) error { - log.Debugf("[devmapper] UnmountDevice(hash=%s)", hash) - defer log.Debugf("[devmapper] UnmountDevice(hash=%s) END", hash) + logrus.Debugf("[devmapper] UnmountDevice(hash=%s)", hash) + defer logrus.Debugf("[devmapper] UnmountDevice(hash=%s) END", hash) info, err := devices.lookupDevice(hash) if err != nil { @@ -1460,11 +1460,11 @@ func (devices *DeviceSet) UnmountDevice(hash string) error { return nil } - log.Debugf("[devmapper] Unmount(%s)", info.mountPath) + logrus.Debugf("[devmapper] Unmount(%s)", info.mountPath) if err := syscall.Unmount(info.mountPath, syscall.MNT_DETACH); err != nil { return err } - log.Debugf("[devmapper] Unmount done") + logrus.Debugf("[devmapper] Unmount done") if err := devices.deactivateDevice(info); err != nil { return err @@ -1586,7 +1586,7 @@ func (devices *DeviceSet) getUnderlyingAvailableSpace(loopFile string) (uint64, buf := new(syscall.Statfs_t) err := syscall.Statfs(loopFile, buf) if err != nil { - log.Warnf("Couldn't stat loopfile filesystem %v: %v", loopFile, err) + logrus.Warnf("Couldn't stat loopfile filesystem %v: %v", loopFile, err) return 0, err } return buf.Bfree * uint64(buf.Bsize), nil @@ -1596,7 +1596,7 @@ func (devices *DeviceSet) isRealFile(loopFile string) (bool, error) { if loopFile != "" { fi, err := os.Stat(loopFile) if err != nil { - log.Warnf("Couldn't stat loopfile %v: %v", loopFile, err) + logrus.Warnf("Couldn't stat loopfile %v: %v", loopFile, err) return false, err } return fi.Mode().IsRegular(), nil diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go index 6dd05ca375a8f67aa6275a88b44272eb1f9bf4f8..fad0a0c55d36cedb47ad01aa510c12a942089fed 100644 --- a/daemon/graphdriver/devmapper/driver.go +++ b/daemon/graphdriver/devmapper/driver.go @@ -8,7 +8,7 @@ import ( "os" "path" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/devicemapper" "github.com/docker/docker/pkg/mount" @@ -164,7 +164,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { func (d *Driver) Put(id string) error { err := d.DeviceSet.UnmountDevice(id) if err != nil { - log.Errorf("Error unmounting device %s: %s", id, err) + logrus.Errorf("Error unmounting device %s: %s", id, err) } return err } diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index 9e7f92a0ed9ca6ae15e722f0869ac597c0f2bbe0..01f1182d11a9ae2b1cd2a82aba8e21b8cb901d33 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -7,7 +7,7 @@ import ( "path" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/archive" ) @@ -184,6 +184,6 @@ func checkPriorDriver(name, root string) { } } if len(priorDrivers) > 0 { - log.Warnf("Graphdriver %s selected. Your graphdriver directory %s already contains data managed by other graphdrivers: %s", name, root, strings.Join(priorDrivers, ",")) + logrus.Warnf("Graphdriver %s selected. Your graphdriver directory %s already contains data managed by other graphdrivers: %s", name, root, strings.Join(priorDrivers, ",")) } } diff --git a/daemon/graphdriver/fsdiff.go b/daemon/graphdriver/fsdiff.go index ab1b08f6204afd53d0cf6a9b812281b6eddf70ce..e091e619b8db2ceb9e69926e6b28819155944440 100644 --- a/daemon/graphdriver/fsdiff.go +++ b/daemon/graphdriver/fsdiff.go @@ -5,7 +5,7 @@ package graphdriver import ( "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/ioutils" @@ -120,11 +120,11 @@ func (gdw *naiveDiffDriver) ApplyDiff(id, parent string, diff archive.ArchiveRea defer driver.Put(id) start := time.Now().UTC() - log.Debugf("Start untar layer") + logrus.Debugf("Start untar layer") if size, err = chrootarchive.ApplyLayer(layerFs, diff); err != nil { return } - log.Debugf("Untar time: %vs", time.Now().UTC().Sub(start).Seconds()) + logrus.Debugf("Untar time: %vs", time.Now().UTC().Sub(start).Seconds()) return } diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index fa5e9a2bf222978be26e22a2d34d401237dcf1d4..5b0d3b7f53a4e5726c50a3805c9490f624ad144b 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -12,7 +12,7 @@ import ( "sync" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" @@ -113,13 +113,13 @@ func Init(home string, options []string) (graphdriver.Driver, error) { // check if they are running over btrfs or aufs switch fsMagic { case graphdriver.FsMagicBtrfs: - log.Error("'overlay' is not supported over btrfs.") + logrus.Error("'overlay' is not supported over btrfs.") return nil, graphdriver.ErrIncompatibleFS case graphdriver.FsMagicAufs: - log.Error("'overlay' is not supported over aufs.") + logrus.Error("'overlay' is not supported over aufs.") return nil, graphdriver.ErrIncompatibleFS case graphdriver.FsMagicZfs: - log.Error("'overlay' is not supported over zfs.") + logrus.Error("'overlay' is not supported over zfs.") return nil, graphdriver.ErrIncompatibleFS } @@ -153,7 +153,7 @@ func supportsOverlay() error { return nil } } - log.Error("'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.") + logrus.Error("'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.") return graphdriver.ErrNotSupported } @@ -317,7 +317,7 @@ func (d *Driver) Put(id string) error { mount := d.active[id] if mount == nil { - log.Debugf("Put on a non-mounted device %s", id) + logrus.Debugf("Put on a non-mounted device %s", id) return nil } @@ -330,7 +330,7 @@ func (d *Driver) Put(id string) error { if mount.mounted { err := syscall.Unmount(mount.path, 0) if err != nil { - log.Debugf("Failed to unmount %s overlay: %v", id, err) + logrus.Debugf("Failed to unmount %s overlay: %v", id, err) } return err } diff --git a/daemon/info.go b/daemon/info.go index 91ac5c6a64ec6583129e9a49dc5fac1fbe0fc36b..8e343fb623b171e421cb502c1c8408770f213506 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -5,7 +5,7 @@ import ( "runtime" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/parsers/kernel" @@ -33,7 +33,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) error { operatingSystem = s } if inContainer, err := operatingsystem.IsContainerized(); err != nil { - log.Errorf("Could not determine if daemon is containerized: %v", err) + logrus.Errorf("Could not determine if daemon is containerized: %v", err) operatingSystem += " (error determining if containerized)" } else if inContainer { operatingSystem += " (containerized)" @@ -41,7 +41,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) error { meminfo, err := system.ReadMemInfo() if err != nil { - log.Errorf("Could not read system memory info: %v", err) + logrus.Errorf("Could not read system memory info: %v", err) } // if we still have the original dockerinit binary from before we copied it locally, let's return the path to that, since that's more intuitive (the copied path is trivial to derive by hand given VERSION) diff --git a/daemon/logs.go b/daemon/logs.go index 14e6aa7941ff37338008a0b718740505444f08d2..c991fa1978a4693c76e5bfc21788d85573b663df 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -9,7 +9,7 @@ import ( "strconv" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/jsonlog" "github.com/docker/docker/pkg/tailfile" @@ -50,31 +50,31 @@ func (daemon *Daemon) ContainerLogs(job *engine.Job) error { cLog, err := container.ReadLog("json") if err != nil && os.IsNotExist(err) { // Legacy logs - log.Debugf("Old logs format") + logrus.Debugf("Old logs format") if stdout { cLog, err := container.ReadLog("stdout") if err != nil { - log.Errorf("Error reading logs (stdout): %s", err) + logrus.Errorf("Error reading logs (stdout): %s", err) } else if _, err := io.Copy(job.Stdout, cLog); err != nil { - log.Errorf("Error streaming logs (stdout): %s", err) + logrus.Errorf("Error streaming logs (stdout): %s", err) } } if stderr { cLog, err := container.ReadLog("stderr") if err != nil { - log.Errorf("Error reading logs (stderr): %s", err) + logrus.Errorf("Error reading logs (stderr): %s", err) } else if _, err := io.Copy(job.Stderr, cLog); err != nil { - log.Errorf("Error streaming logs (stderr): %s", err) + logrus.Errorf("Error streaming logs (stderr): %s", err) } } } else if err != nil { - log.Errorf("Error reading logs (json): %s", err) + logrus.Errorf("Error reading logs (json): %s", err) } else { if tail != "all" { var err error lines, err = strconv.Atoi(tail) if err != nil { - log.Errorf("Failed to parse tail %s, error: %v, show all logs", tail, err) + logrus.Errorf("Failed to parse tail %s, error: %v, show all logs", tail, err) lines = -1 } } @@ -97,7 +97,7 @@ func (daemon *Daemon) ContainerLogs(job *engine.Job) error { if err := dec.Decode(l); err == io.EOF { break } else if err != nil { - log.Errorf("Error streaming logs: %s", err) + logrus.Errorf("Error streaming logs: %s", err) break } logLine := l.Log @@ -143,7 +143,7 @@ func (daemon *Daemon) ContainerLogs(job *engine.Job) error { for err := range errors { if err != nil { - log.Errorf("%s", err) + logrus.Errorf("%s", err) } } diff --git a/daemon/monitor.go b/daemon/monitor.go index abe7dea2b22f019da4c80beae54aa3655660e559..293849dd364b4036c2f962866a2717d14b6c1f73 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -6,7 +6,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/runconfig" @@ -89,7 +89,7 @@ func (m *containerMonitor) Close() error { // because they share same runconfig and change image. Must be fixed // in builder/builder.go if err := m.container.toDisk(); err != nil { - log.Errorf("Error dumping container %s state to disk: %s", m.container.ID, err) + logrus.Errorf("Error dumping container %s state to disk: %s", m.container.ID, err) return err } @@ -145,7 +145,7 @@ func (m *containerMonitor) Start() error { return err } - log.Errorf("Error running container: %s", err) + logrus.Errorf("Error running container: %s", err) } // here container.Lock is already lost @@ -229,7 +229,7 @@ func (m *containerMonitor) shouldRestart(exitCode int) bool { case "on-failure": // the default value of 0 for MaximumRetryCount means that we will not enforce a maximum count if max := m.restartPolicy.MaximumRetryCount; max != 0 && m.failureCount > max { - log.Debugf("stopping restart of container %s because maximum failure could of %d has been reached", + logrus.Debugf("stopping restart of container %s because maximum failure could of %d has been reached", stringid.TruncateID(m.container.ID), max) return false } @@ -263,7 +263,7 @@ func (m *containerMonitor) callback(processConfig *execdriver.ProcessConfig, pid } if err := m.container.ToDisk(); err != nil { - log.Debugf("%s", err) + logrus.Debugf("%s", err) } } @@ -279,21 +279,21 @@ func (m *containerMonitor) resetContainer(lock bool) { if container.Config.OpenStdin { if err := container.stdin.Close(); err != nil { - log.Errorf("%s: Error close stdin: %s", container.ID, err) + logrus.Errorf("%s: Error close stdin: %s", container.ID, err) } } if err := container.stdout.Clean(); err != nil { - log.Errorf("%s: Error close stdout: %s", container.ID, err) + logrus.Errorf("%s: Error close stdout: %s", container.ID, err) } if err := container.stderr.Clean(); err != nil { - log.Errorf("%s: Error close stderr: %s", container.ID, err) + logrus.Errorf("%s: Error close stderr: %s", container.ID, err) } if container.command != nil && container.command.ProcessConfig.Terminal != nil { if err := container.command.ProcessConfig.Terminal.Close(); err != nil { - log.Errorf("%s: Error closing terminal: %s", container.ID, err) + logrus.Errorf("%s: Error closing terminal: %s", container.ID, err) } } @@ -311,7 +311,7 @@ func (m *containerMonitor) resetContainer(lock bool) { }() select { case <-time.After(1 * time.Second): - log.Warnf("Logger didn't exit in time: logs may be truncated") + logrus.Warnf("Logger didn't exit in time: logs may be truncated") case <-exit: } } diff --git a/daemon/networkdriver/bridge/driver.go b/daemon/networkdriver/bridge/driver.go index 61237ebe90abf998411c8eb1492bd03e6060973c..6f65423e2768a4032ee348b63d482d11229e7238 100644 --- a/daemon/networkdriver/bridge/driver.go +++ b/daemon/networkdriver/bridge/driver.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/networkdriver" "github.com/docker/docker/daemon/networkdriver/ipallocator" "github.com/docker/docker/daemon/networkdriver/portmapper" @@ -132,9 +132,9 @@ func InitDriver(job *engine.Job) error { if fixedCIDRv6 != "" { // Setting route to global IPv6 subnet - log.Infof("Adding route to IPv6 network %q via device %q", fixedCIDRv6, bridgeIface) + logrus.Infof("Adding route to IPv6 network %q via device %q", fixedCIDRv6, bridgeIface) if err := netlink.AddRoute(fixedCIDRv6, "", "", bridgeIface); err != nil { - log.Fatalf("Could not add route to IPv6 network %q via device %q", fixedCIDRv6, bridgeIface) + logrus.Fatalf("Could not add route to IPv6 network %q via device %q", fixedCIDRv6, bridgeIface) } } } else { @@ -207,16 +207,16 @@ func InitDriver(job *engine.Job) error { if ipForward { // Enable IPv4 forwarding if err := ioutil.WriteFile("/proc/sys/net/ipv4/ip_forward", []byte{'1', '\n'}, 0644); err != nil { - log.Warnf("WARNING: unable to enable IPv4 forwarding: %s\n", err) + logrus.Warnf("WARNING: unable to enable IPv4 forwarding: %s\n", err) } if fixedCIDRv6 != "" { // Enable IPv6 forwarding if err := ioutil.WriteFile("/proc/sys/net/ipv6/conf/default/forwarding", []byte{'1', '\n'}, 0644); err != nil { - log.Warnf("WARNING: unable to enable IPv6 default forwarding: %s\n", err) + logrus.Warnf("WARNING: unable to enable IPv6 default forwarding: %s\n", err) } if err := ioutil.WriteFile("/proc/sys/net/ipv6/conf/all/forwarding", []byte{'1', '\n'}, 0644); err != nil { - log.Warnf("WARNING: unable to enable IPv6 all forwarding: %s\n", err) + logrus.Warnf("WARNING: unable to enable IPv6 all forwarding: %s\n", err) } } } @@ -244,7 +244,7 @@ func InitDriver(job *engine.Job) error { if err != nil { return err } - log.Debugf("Subnet: %v", subnet) + logrus.Debugf("Subnet: %v", subnet) if err := ipAllocator.RegisterSubnet(bridgeIPv4Network, subnet); err != nil { return err } @@ -255,7 +255,7 @@ func InitDriver(job *engine.Job) error { if err != nil { return err } - log.Debugf("Subnet: %v", subnet) + logrus.Debugf("Subnet: %v", subnet) if err := ipAllocator.RegisterSubnet(subnet, subnet); err != nil { return err } @@ -307,7 +307,7 @@ func setupIPTables(addr net.Addr, icc, ipmasq bool) error { iptables.Raw(append([]string{"-D", "FORWARD"}, acceptArgs...)...) if !iptables.Exists(iptables.Filter, "FORWARD", dropArgs...) { - log.Debugf("Disable inter-container communication") + logrus.Debugf("Disable inter-container communication") if output, err := iptables.Raw(append([]string{"-I", "FORWARD"}, dropArgs...)...); err != nil { return fmt.Errorf("Unable to prevent intercontainer communication: %s", err) } else if len(output) != 0 { @@ -318,7 +318,7 @@ func setupIPTables(addr net.Addr, icc, ipmasq bool) error { iptables.Raw(append([]string{"-D", "FORWARD"}, dropArgs...)...) if !iptables.Exists(iptables.Filter, "FORWARD", acceptArgs...) { - log.Debugf("Enable inter-container communication") + logrus.Debugf("Enable inter-container communication") if output, err := iptables.Raw(append([]string{"-I", "FORWARD"}, acceptArgs...)...); err != nil { return fmt.Errorf("Unable to allow intercontainer communication: %s", err) } else if len(output) != 0 { @@ -384,7 +384,7 @@ func configureBridge(bridgeIP string, bridgeIPv6 string, enableIPv6 bool) error ifaceAddr = addr break } else { - log.Debugf("%s %s", addr, err) + logrus.Debugf("%s %s", addr, err) } } } @@ -393,7 +393,7 @@ func configureBridge(bridgeIP string, bridgeIPv6 string, enableIPv6 bool) error if ifaceAddr == "" { return fmt.Errorf("Could not find a free IP address range for interface '%s'. Please configure its address manually and run 'docker -b %s'", bridgeIface, bridgeIface) } - log.Debugf("Creating bridge %s with network %s", bridgeIface, ifaceAddr) + logrus.Debugf("Creating bridge %s with network %s", bridgeIface, ifaceAddr) if err := createBridgeIface(bridgeIface); err != nil { // The bridge may already exist, therefore we can ignore an "exists" error @@ -457,7 +457,7 @@ func createBridgeIface(name string) error { // Only set the bridge's mac address if the kernel version is > 3.3 // before that it was not supported setBridgeMacAddr := err == nil && (kv.Kernel >= 3 && kv.Major >= 3) - log.Debugf("setting bridge mac address = %v", setBridgeMacAddr) + logrus.Debugf("setting bridge mac address = %v", setBridgeMacAddr) return netlink.CreateBridge(name, setBridgeMacAddr) } @@ -533,10 +533,10 @@ func Allocate(job *engine.Job) error { globalIPv6, err = ipAllocator.RequestIP(globalIPv6Network, requestedIPv6) if err != nil { - log.Errorf("Allocator: RequestIP v6: %v", err) + logrus.Errorf("Allocator: RequestIP v6: %v", err) return err } - log.Infof("Allocated IPv6 %s", globalIPv6) + logrus.Infof("Allocated IPv6 %s", globalIPv6) } out := engine.Env{} @@ -588,16 +588,16 @@ func Release(job *engine.Job) error { for _, nat := range containerInterface.PortMappings { if err := portmapper.Unmap(nat); err != nil { - log.Infof("Unable to unmap port %s: %s", nat, err) + logrus.Infof("Unable to unmap port %s: %s", nat, err) } } if err := ipAllocator.ReleaseIP(bridgeIPv4Network, containerInterface.IP); err != nil { - log.Infof("Unable to release IPv4 %s", err) + logrus.Infof("Unable to release IPv4 %s", err) } if globalIPv6Network != nil { if err := ipAllocator.ReleaseIP(globalIPv6Network, containerInterface.IPv6); err != nil { - log.Infof("Unable to release IPv6 %s", err) + logrus.Infof("Unable to release IPv6 %s", err) } } return nil @@ -650,10 +650,10 @@ func AllocatePort(job *engine.Job) error { // There is no point in immediately retrying to map an explicitly // chosen port. if hostPort != 0 { - log.Warnf("Failed to allocate and map port %d: %s", hostPort, err) + logrus.Warnf("Failed to allocate and map port %d: %s", hostPort, err) break } - log.Warnf("Failed to allocate and map port: %s, retry: %d", err, i+1) + logrus.Warnf("Failed to allocate and map port: %s, retry: %d", err, i+1) } if err != nil { diff --git a/daemon/networkdriver/ipallocator/allocator.go b/daemon/networkdriver/ipallocator/allocator.go index 628500d0d9d0d35a8223394dcff1631c5aa38ccc..62935e1759e29da02d8f781263ef3482c12361ed 100644 --- a/daemon/networkdriver/ipallocator/allocator.go +++ b/daemon/networkdriver/ipallocator/allocator.go @@ -6,7 +6,7 @@ import ( "net" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/networkdriver" ) @@ -157,7 +157,7 @@ func ipToBigInt(ip net.IP) *big.Int { return x.SetBytes(ip6) } - log.Errorf("ipToBigInt: Wrong IP length! %s", ip) + logrus.Errorf("ipToBigInt: Wrong IP length! %s", ip) return nil } diff --git a/daemon/networkdriver/portallocator/portallocator.go b/daemon/networkdriver/portallocator/portallocator.go index 01533419bd8821fc720149aa36d8ba6ceaa1a7b1..e2bb9ee56bfdfe4195eb8b5d117ebf644d4863ef 100644 --- a/daemon/networkdriver/portallocator/portallocator.go +++ b/daemon/networkdriver/portallocator/portallocator.go @@ -8,7 +8,7 @@ import ( "os" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) const ( @@ -87,7 +87,7 @@ func init() { file, err := os.Open(portRangeKernelParam) if err != nil { - log.Warnf("port allocator - %s due to error: %v", portRangeFallback, err) + logrus.Warnf("port allocator - %s due to error: %v", portRangeFallback, err) return } var start, end int @@ -96,7 +96,7 @@ func init() { if err == nil { err = fmt.Errorf("unexpected count of parsed numbers (%d)", n) } - log.Errorf("port allocator - failed to parse system ephemeral port range from %s - %s: %v", portRangeKernelParam, portRangeFallback, err) + logrus.Errorf("port allocator - failed to parse system ephemeral port range from %s - %s: %v", portRangeKernelParam, portRangeFallback, err) return } beginPortRange = start diff --git a/daemon/networkdriver/portmapper/mapper.go b/daemon/networkdriver/portmapper/mapper.go index 74b329e2f7b13a224c6537636a028015b9e547a2..a01b604160268941fe1be02b82dfa949218099b6 100644 --- a/daemon/networkdriver/portmapper/mapper.go +++ b/daemon/networkdriver/portmapper/mapper.go @@ -6,7 +6,7 @@ import ( "net" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/networkdriver/portallocator" "github.com/docker/docker/pkg/iptables" ) @@ -156,7 +156,7 @@ func (pm *PortMapper) Unmap(host net.Addr) error { containerIP, containerPort := getIPAndPort(data.container) hostIP, hostPort := getIPAndPort(data.host) if err := pm.forward(iptables.Delete, data.proto, hostIP, hostPort, containerIP.String(), containerPort); err != nil { - log.Errorf("Error on iptables delete: %s", err) + logrus.Errorf("Error on iptables delete: %s", err) } switch a := host.(type) { diff --git a/daemon/stats_collector.go b/daemon/stats_collector.go index 779bd1a59493cbe88156e2d4bc0642c688a9bd5e..926dd256e4c3768155222ed76eb237197176780b 100644 --- a/daemon/stats_collector.go +++ b/daemon/stats_collector.go @@ -9,7 +9,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/pkg/pubsub" "github.com/docker/libcontainer/system" @@ -80,13 +80,13 @@ func (s *statsCollector) run() { for container, publisher := range s.publishers { systemUsage, err := s.getSystemCpuUsage() if err != nil { - log.Errorf("collecting system cpu usage for %s: %v", container.ID, err) + logrus.Errorf("collecting system cpu usage for %s: %v", container.ID, err) continue } stats, err := container.Stats() if err != nil { if err != execdriver.ErrNotRunning { - log.Errorf("collecting stats for %s: %v", container.ID, err) + logrus.Errorf("collecting stats for %s: %v", container.ID, err) } continue } diff --git a/daemon/volumes.go b/daemon/volumes.go index 126d74a383a43cc5fcad6f88440fcea5e3dce42f..a4645dab268cc16534a36d5743e933fd425b50f7 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/symlink" @@ -133,7 +133,7 @@ func (container *Container) registerVolumes() { } v, err := container.daemon.volumes.FindOrCreateVolume(path, writable) if err != nil { - log.Debugf("error registering volume %s: %v", path, err) + logrus.Debugf("error registering volume %s: %v", path, err) continue } v.AddContainer(container.ID) @@ -144,7 +144,7 @@ func (container *Container) derefVolumes() { for path := range container.VolumePaths() { vol := container.daemon.volumes.Get(path) if vol == nil { - log.Debugf("Volume %s was not found and could not be dereferenced", path) + logrus.Debugf("Volume %s was not found and could not be dereferenced", path) continue } vol.RemoveContainer(container.ID) diff --git a/docker/daemon.go b/docker/daemon.go index b2a985b2210a7d4cf2b8eb3a991b52743814d8dc..c4b43d915ed0bbc3247043ad598e3cb5335c76db 100644 --- a/docker/daemon.go +++ b/docker/daemon.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/builder" "github.com/docker/docker/builtins" @@ -46,7 +46,7 @@ func migrateKey() (err error) { if err == nil { err = os.Remove(oldPath) } else { - log.Warnf("Key migration failed, key file not removed at %s", oldPath) + logrus.Warnf("Key migration failed, key file not removed at %s", oldPath) } }() @@ -70,7 +70,7 @@ func migrateKey() (err error) { return fmt.Errorf("error copying key: %s", err) } - log.Infof("Migrated key from %s to %s", oldPath, newPath) + logrus.Infof("Migrated key from %s to %s", oldPath, newPath) } return nil @@ -85,18 +85,18 @@ func mainDaemon() { signal.Trap(eng.Shutdown) if err := migrateKey(); err != nil { - log.Fatal(err) + logrus.Fatal(err) } daemonCfg.TrustKeyPath = *flTrustKey // Load builtins if err := builtins.Register(eng); err != nil { - log.Fatal(err) + logrus.Fatal(err) } // load registry service if err := registry.NewService(registryCfg).Install(eng); err != nil { - log.Fatal(err) + logrus.Fatal(err) } // load the daemon in the background so we can immediately start @@ -110,7 +110,7 @@ func mainDaemon() { return } - log.Infof("docker daemon: %s %s; execdriver: %s; graphdriver: %s", + logrus.Infof("docker daemon: %s %s; execdriver: %s; graphdriver: %s", dockerversion.VERSION, dockerversion.GITCOMMIT, d.ExecutionDriver().Name(), @@ -155,7 +155,7 @@ func mainDaemon() { serveAPIWait := make(chan error) go func() { if err := job.Run(); err != nil { - log.Errorf("ServeAPI error: %v", err) + logrus.Errorf("ServeAPI error: %v", err) serveAPIWait <- err return } @@ -164,7 +164,7 @@ func mainDaemon() { // Wait for the daemon startup goroutine to finish // This makes sure we can actually cleanly shutdown the daemon - log.Debug("waiting for daemon to initialize") + logrus.Debug("waiting for daemon to initialize") errDaemon := <-daemonInitWait if errDaemon != nil { eng.Shutdown() @@ -176,9 +176,9 @@ func mainDaemon() { } // we must "fatal" exit here as the API server may be happy to // continue listening forever if the error had no impact to API - log.Fatal(outStr) + logrus.Fatal(outStr) } else { - log.Info("Daemon has completed initialization") + logrus.Info("Daemon has completed initialization") } // Daemon is fully initialized and handling API traffic @@ -188,7 +188,7 @@ func mainDaemon() { // exited the daemon process above) eng.Shutdown() if errAPI != nil { - log.Fatalf("Shutting down due to ServeAPI error: %v", errAPI) + logrus.Fatalf("Shutting down due to ServeAPI error: %v", errAPI) } } diff --git a/docker/docker.go b/docker/docker.go index 347424432bc5ee6e51cc170363c64d68e704790a..c9b2c77b02c2f001dde3a7f1987016bf0ec1abe7 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -8,7 +8,7 @@ import ( "os" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/api/client" "github.com/docker/docker/autogen/dockerversion" @@ -44,20 +44,20 @@ func main() { } if *flLogLevel != "" { - lvl, err := log.ParseLevel(*flLogLevel) + lvl, err := logrus.ParseLevel(*flLogLevel) if err != nil { - log.Fatalf("Unable to parse logging level: %s", *flLogLevel) + logrus.Fatalf("Unable to parse logging level: %s", *flLogLevel) } setLogLevel(lvl) } else { - setLogLevel(log.InfoLevel) + setLogLevel(logrus.InfoLevel) } // -D, --debug, -l/--log-level=debug processing // When/if -D is removed this block can be deleted if *flDebug { os.Setenv("DEBUG", "1") - setLogLevel(log.DebugLevel) + setLogLevel(logrus.DebugLevel) } if len(flHosts) == 0 { @@ -68,7 +68,7 @@ func main() { } defaultHost, err := api.ValidateHost(defaultHost) if err != nil { - log.Fatal(err) + logrus.Fatal(err) } flHosts = append(flHosts, defaultHost) } @@ -85,7 +85,7 @@ func main() { } if len(flHosts) > 1 { - log.Fatal("Please specify only one -H") + logrus.Fatal("Please specify only one -H") } protoAddrParts := strings.SplitN(flHosts[0], "://", 2) @@ -106,7 +106,7 @@ func main() { certPool := x509.NewCertPool() file, err := ioutil.ReadFile(*flCa) if err != nil { - log.Fatalf("Couldn't read ca cert %s: %s", *flCa, err) + logrus.Fatalf("Couldn't read ca cert %s: %s", *flCa, err) } certPool.AppendCertsFromPEM(file) tlsConfig.RootCAs = certPool @@ -121,7 +121,7 @@ func main() { *flTls = true cert, err := tls.LoadX509KeyPair(*flCert, *flKey) if err != nil { - log.Fatalf("Couldn't load X509 key pair: %q. Make sure the key is encrypted", err) + logrus.Fatalf("Couldn't load X509 key pair: %q. Make sure the key is encrypted", err) } tlsConfig.Certificates = []tls.Certificate{cert} } @@ -138,11 +138,11 @@ func main() { if err := cli.Cmd(flag.Args()...); err != nil { if sterr, ok := err.(*utils.StatusError); ok { if sterr.Status != "" { - log.Println(sterr.Status) + logrus.Println(sterr.Status) } os.Exit(sterr.StatusCode) } - log.Fatal(err) + logrus.Fatal(err) } } diff --git a/docker/log.go b/docker/log.go index 0dd9a70eebf473fd333facea81aea970b9715b61..7b43b56f5f51baf731fc2c7676f31ba1712133c9 100644 --- a/docker/log.go +++ b/docker/log.go @@ -1,14 +1,14 @@ package main import ( - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "io" ) -func setLogLevel(lvl log.Level) { - log.SetLevel(lvl) +func setLogLevel(lvl logrus.Level) { + logrus.SetLevel(lvl) } func initLogging(stderr io.Writer) { - log.SetOutput(stderr) + logrus.SetOutput(stderr) } diff --git a/engine/job.go b/engine/job.go index 52c655bae2466fbc4e629ccf67998fd1add8b7aa..189061bf5ec912375b98d6160b8697d9b244b10c 100644 --- a/engine/job.go +++ b/engine/job.go @@ -8,7 +8,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) // A job is the fundamental unit of work in the docker engine. @@ -67,10 +67,10 @@ func (job *Job) Run() error { } // Log beginning and end of the job if job.Eng.Logging { - log.Infof("+job %s", job.CallString()) + logrus.Infof("+job %s", job.CallString()) defer func() { // what if err is nil? - log.Infof("-job %s%s", job.CallString(), job.err) + logrus.Infof("-job %s%s", job.CallString(), job.err) }() } var errorMessage = bytes.NewBuffer(nil) diff --git a/graph/export.go b/graph/export.go index a4c9278bc1298761a933d4f1f14d908ea5dc8f0e..f689ba10efbe0e123030eaa7ee78a002b4ee141d 100644 --- a/graph/export.go +++ b/graph/export.go @@ -8,7 +8,7 @@ import ( "os" "path" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/parsers" @@ -33,7 +33,7 @@ func (s *TagStore) CmdImageExport(job *engine.Job) error { rootRepoMap := map[string]Repository{} addKey := func(name string, tag string, id string) { - log.Debugf("add key [%s:%s]", name, tag) + logrus.Debugf("add key [%s:%s]", name, tag) if repo, ok := rootRepoMap[name]; !ok { rootRepoMap[name] = Repository{tag: id} } else { @@ -42,7 +42,7 @@ func (s *TagStore) CmdImageExport(job *engine.Job) error { } for _, name := range job.Args { name = registry.NormalizeLocalName(name) - log.Debugf("Serializing %s", name) + logrus.Debugf("Serializing %s", name) rootRepo := s.Repositories[name] if rootRepo != nil { // this is a base repo name, like 'busybox' @@ -78,7 +78,7 @@ func (s *TagStore) CmdImageExport(job *engine.Job) error { } } } - log.Debugf("End Serializing %s", name) + logrus.Debugf("End Serializing %s", name) } // write repositories, if there is something to write if len(rootRepoMap) > 0 { @@ -87,7 +87,7 @@ func (s *TagStore) CmdImageExport(job *engine.Job) error { return err } } else { - log.Debugf("There were no repositories to write") + logrus.Debugf("There were no repositories to write") } fs, err := archive.Tar(tempdir, archive.Uncompressed) @@ -99,7 +99,7 @@ func (s *TagStore) CmdImageExport(job *engine.Job) error { if _, err := io.Copy(job.Stdout, fs); err != nil { return err } - log.Debugf("End export job: %s", job.Name) + logrus.Debugf("End export job: %s", job.Name) return nil } diff --git a/graph/graph.go b/graph/graph.go index 902018e39cc16252d709126e7c2ad02fd0924831..933269a435b998ce3be2c87f5c924fb046204552 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -12,7 +12,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/image" @@ -68,7 +68,7 @@ func (graph *Graph) restore() error { } } graph.idIndex = truncindex.NewTruncIndex(ids) - log.Debugf("Restored %d elements", len(dir)) + logrus.Debugf("Restored %d elements", len(dir)) return nil } diff --git a/graph/import.go b/graph/import.go index 2b3e8bdd6e36b3c44624f80b6ba92325e44bf258..8b9918896959d4abf8d7cc8f2908e58a5d0d5509 100644 --- a/graph/import.go +++ b/graph/import.go @@ -7,7 +7,7 @@ import ( "net/http" "net/url" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/progressreader" @@ -93,7 +93,7 @@ func (s *TagStore) CmdImport(job *engine.Job) error { logID = utils.ImageReference(logID, tag) } if err = job.Eng.Job("log", "import", logID, "").Run(); err != nil { - log.Errorf("Error logging event 'import' for %s: %s", logID, err) + logrus.Errorf("Error logging event 'import' for %s: %s", logID, err) } return nil } diff --git a/graph/load.go b/graph/load.go index 08c7bd8779d32eab1262c3bcd99be35c5e3ce8f7..a3a75bce4d731c884b33160fd116611036ffdd43 100644 --- a/graph/load.go +++ b/graph/load.go @@ -8,7 +8,7 @@ import ( "os" "path" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/image" "github.com/docker/docker/pkg/archive" @@ -82,33 +82,33 @@ func (s *TagStore) CmdLoad(job *engine.Job) error { func (s *TagStore) recursiveLoad(eng *engine.Engine, address, tmpImageDir string) error { if err := eng.Job("image_get", address).Run(); err != nil { - log.Debugf("Loading %s", address) + logrus.Debugf("Loading %s", address) imageJson, err := ioutil.ReadFile(path.Join(tmpImageDir, "repo", address, "json")) if err != nil { - log.Debugf("Error reading json", err) + logrus.Debugf("Error reading json", err) return err } layer, err := os.Open(path.Join(tmpImageDir, "repo", address, "layer.tar")) if err != nil { - log.Debugf("Error reading embedded tar", err) + logrus.Debugf("Error reading embedded tar", err) return err } img, err := image.NewImgJSON(imageJson) if err != nil { - log.Debugf("Error unmarshalling json", err) + logrus.Debugf("Error unmarshalling json", err) return err } if err := utils.ValidateID(img.ID); err != nil { - log.Debugf("Error validating ID: %s", err) + logrus.Debugf("Error validating ID: %s", err) return err } // ensure no two downloads of the same layer happen at the same time if c, err := s.poolAdd("pull", "layer:"+img.ID); err != nil { if c != nil { - log.Debugf("Image (id: %s) load is already running, waiting: %v", img.ID, err) + logrus.Debugf("Image (id: %s) load is already running, waiting: %v", img.ID, err) <-c return nil } @@ -129,7 +129,7 @@ func (s *TagStore) recursiveLoad(eng *engine.Engine, address, tmpImageDir string return err } } - log.Debugf("Completed processing %s", address) + logrus.Debugf("Completed processing %s", address) return nil } diff --git a/graph/manifest.go b/graph/manifest.go index 3b1d8255762a9bb2766b889f1e62250cbf85d6cf..7e9281537e3bd2060fa08db2b37c45afdce46a18 100644 --- a/graph/manifest.go +++ b/graph/manifest.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" "github.com/docker/docker/engine" "github.com/docker/docker/registry" @@ -89,7 +89,7 @@ func (s *TagStore) loadManifest(eng *engine.Engine, manifestBytes []byte, dgst, return nil, false, fmt.Errorf("error running key check: %s", err) } result := engine.Tail(stdoutBuffer, 1) - log.Debugf("Key check result: %q", result) + logrus.Debugf("Key check result: %q", result) if result == "verified" { verified = true } diff --git a/graph/pull.go b/graph/pull.go index 0a6b2800c06ad3df149617e30fc2bf77fb3a672e..2fe5d92e6a56eb8e83b6ca41fc1b1ba2bf018a3f 100644 --- a/graph/pull.go +++ b/graph/pull.go @@ -10,7 +10,7 @@ import ( "strings" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" "github.com/docker/docker/engine" "github.com/docker/docker/image" @@ -59,7 +59,7 @@ func (s *TagStore) CmdPull(job *engine.Job) error { } defer s.poolRemove("pull", utils.ImageReference(repoInfo.LocalName, tag)) - log.Debugf("pulling image from host %q with remote name %q", repoInfo.Index.Name, repoInfo.RemoteName) + logrus.Debugf("pulling image from host %q with remote name %q", repoInfo.Index.Name, repoInfo.RemoteName) endpoint, err := repoInfo.GetEndpoint() if err != nil { return err @@ -79,30 +79,30 @@ func (s *TagStore) CmdPull(job *engine.Job) error { if repoInfo.Official { j := job.Eng.Job("trust_update_base") if err = j.Run(); err != nil { - log.Errorf("error updating trust base graph: %s", err) + logrus.Errorf("error updating trust base graph: %s", err) } } - log.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName) + logrus.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName) if err := s.pullV2Repository(job.Eng, r, job.Stdout, repoInfo, tag, sf, job.GetenvBool("parallel")); err == nil { if err = job.Eng.Job("log", "pull", logName, "").Run(); err != nil { - log.Errorf("Error logging event 'pull' for %s: %s", logName, err) + logrus.Errorf("Error logging event 'pull' for %s: %s", logName, err) } return nil } else if err != registry.ErrDoesNotExist && err != ErrV2RegistryUnavailable { - log.Errorf("Error from V2 registry: %s", err) + logrus.Errorf("Error from V2 registry: %s", err) } - log.Debug("image does not exist on v2 registry, falling back to v1") + logrus.Debug("image does not exist on v2 registry, falling back to v1") } - log.Debugf("pulling v1 repository with local name %q", repoInfo.LocalName) + logrus.Debugf("pulling v1 repository with local name %q", repoInfo.LocalName) if err = s.pullRepository(r, job.Stdout, repoInfo, tag, sf, job.GetenvBool("parallel")); err != nil { return err } if err = job.Eng.Job("log", "pull", logName, "").Run(); err != nil { - log.Errorf("Error logging event 'pull' for %s: %s", logName, err) + logrus.Errorf("Error logging event 'pull' for %s: %s", logName, err) } return nil @@ -120,10 +120,10 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * return err } - log.Debugf("Retrieving the tag list") + logrus.Debugf("Retrieving the tag list") tagsList, err := r.GetRemoteTags(repoData.Endpoints, repoInfo.RemoteName, repoData.Tokens) if err != nil { - log.Errorf("unable to get remote tags: %s", err) + logrus.Errorf("unable to get remote tags: %s", err) return err } @@ -135,7 +135,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * } } - log.Debugf("Registering tags") + logrus.Debugf("Registering tags") // If no tag has been specified, pull them all if askedTag == "" { for tag, id := range tagsList { @@ -163,7 +163,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * } if img.Tag == "" { - log.Debugf("Image (id: %s) present in this repository but untagged, skipping", img.ID) + logrus.Debugf("Image (id: %s) present in this repository but untagged, skipping", img.ID) if parallel { errors <- nil } @@ -177,7 +177,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * <-c out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Download complete", nil)) } else { - log.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err) + logrus.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err) } if parallel { errors <- nil @@ -194,7 +194,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), fmt.Sprintf("Pulling image (%s) from %s, mirror: %s", img.Tag, repoInfo.CanonicalName, ep), nil)) if is_downloaded, err = s.pullImage(r, out, img.ID, ep, repoData.Tokens, sf); err != nil { // Don't report errors when pulling from mirrors. - log.Debugf("Error pulling image (%s) from %s, mirror: %s, %s", img.Tag, repoInfo.CanonicalName, ep, err) + logrus.Debugf("Error pulling image (%s) from %s, mirror: %s, %s", img.Tag, repoInfo.CanonicalName, ep, err) continue } layers_downloaded = layers_downloaded || is_downloaded @@ -281,7 +281,7 @@ func (s *TagStore) pullImage(r *registry.Session, out io.Writer, imgID, endpoint // ensure no two downloads of the same layer happen at the same time if c, err := s.poolAdd("pull", "layer:"+id); err != nil { - log.Debugf("Image (id: %s) pull is already running, skipping: %v", id, err) + logrus.Debugf("Image (id: %s) pull is already running, skipping: %v", id, err) <-c } defer s.poolRemove("pull", "layer:"+id) @@ -387,7 +387,7 @@ func (s *TagStore) pullV2Repository(eng *engine.Engine, r *registry.Session, out endpoint, err := r.V2RegistryEndpoint(repoInfo.Index) if err != nil { if repoInfo.Index.Official { - log.Debugf("Unable to pull from V2 registry, falling back to v1: %s", err) + logrus.Debugf("Unable to pull from V2 registry, falling back to v1: %s", err) return ErrV2RegistryUnavailable } return fmt.Errorf("error getting registry endpoint: %s", err) @@ -398,7 +398,7 @@ func (s *TagStore) pullV2Repository(eng *engine.Engine, r *registry.Session, out } var layersDownloaded bool if tag == "" { - log.Debugf("Pulling tag list from V2 registry for %s", repoInfo.CanonicalName) + logrus.Debugf("Pulling tag list from V2 registry for %s", repoInfo.CanonicalName) tags, err := r.GetV2RemoteTags(endpoint, repoInfo.RemoteName, auth) if err != nil { return err @@ -430,7 +430,7 @@ func (s *TagStore) pullV2Repository(eng *engine.Engine, r *registry.Session, out } func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Writer, endpoint *registry.Endpoint, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool, auth *registry.RequestAuthorization) (bool, error) { - log.Debugf("Pulling tag from V2 registry: %q", tag) + logrus.Debugf("Pulling tag from V2 registry: %q", tag) manifestBytes, manifestDigest, err := r.GetV2ImageManifest(endpoint, repoInfo.RemoteName, tag, auth) if err != nil { @@ -449,7 +449,7 @@ func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Wri } if verified { - log.Printf("Image manifest for %s has been verified", utils.ImageReference(repoInfo.CanonicalName, tag)) + logrus.Printf("Image manifest for %s has been verified", utils.ImageReference(repoInfo.CanonicalName, tag)) } out.Write(sf.FormatStatus(tag, "Pulling from %s", repoInfo.CanonicalName)) @@ -469,7 +469,7 @@ func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Wri // Check if exists if s.graph.Exists(img.ID) { - log.Debugf("Image already exists: %s", img.ID) + logrus.Debugf("Image already exists: %s", img.ID) continue } @@ -482,7 +482,7 @@ func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Wri out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Pulling fs layer", nil)) downloadFunc := func(di *downloadInfo) error { - log.Debugf("pulling blob %q to V1 img %s", sumStr, img.ID) + logrus.Debugf("pulling blob %q to V1 img %s", sumStr, img.ID) if c, err := s.poolAdd("pull", "img:"+img.ID); err != nil { if c != nil { @@ -490,7 +490,7 @@ func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Wri <-c out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Download complete", nil)) } else { - log.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err) + logrus.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err) } } else { defer s.poolRemove("pull", "img:"+img.ID) @@ -525,13 +525,13 @@ func (s *TagStore) pullV2Tag(eng *engine.Engine, r *registry.Session, out io.Wri out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Verifying Checksum", nil)) if !verifier.Verified() { - log.Infof("Image verification failed: checksum mismatch for %q", di.digest.String()) + logrus.Infof("Image verification failed: checksum mismatch for %q", di.digest.String()) verified = false } out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Download complete", nil)) - log.Debugf("Downloaded %s to tempfile %s", img.ID, tmpFile.Name()) + logrus.Debugf("Downloaded %s to tempfile %s", img.ID, tmpFile.Name()) di.tmpFile = tmpFile di.length = l di.downloaded = true diff --git a/graph/push.go b/graph/push.go index 4bd80f1207a29b4aa55b53effbdb35735f3df33f..927c13c9d5d8b77a2b87b3ae40d12197a03737e9 100644 --- a/graph/push.go +++ b/graph/push.go @@ -12,7 +12,7 @@ import ( "strings" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" "github.com/docker/docker/engine" "github.com/docker/docker/image" @@ -75,14 +75,14 @@ func (s *TagStore) getImageList(localRepo map[string]string, requestedTag string if len(imageList) == 0 { return nil, nil, fmt.Errorf("No images found for the requested repository / tag") } - log.Debugf("Image list: %v", imageList) - log.Debugf("Tags by image: %v", tagsByImage) + logrus.Debugf("Image list: %v", imageList) + logrus.Debugf("Tags by image: %v", tagsByImage) return imageList, tagsByImage, nil } func (s *TagStore) getImageTags(localRepo map[string]string, askedTag string) ([]string, error) { - log.Debugf("Checking %s against %#v", askedTag, localRepo) + logrus.Debugf("Checking %s against %#v", askedTag, localRepo) if len(askedTag) > 0 { if _, ok := localRepo[askedTag]; !ok || utils.DigestReference(askedTag) { return nil, fmt.Errorf("Tag does not exist: %s", askedTag) @@ -136,7 +136,7 @@ func lookupImageOnEndpoint(wg *sync.WaitGroup, r *registry.Session, out io.Write defer wg.Done() for image := range images { if err := r.LookupRemoteImage(image.id, image.endpoint, image.tokens); err != nil { - log.Errorf("Error in LookupRemoteImage: %s", err) + logrus.Errorf("Error in LookupRemoteImage: %s", err) imagesToPush <- image.id continue } @@ -205,7 +205,7 @@ func (s *TagStore) pushImageToEndpoint(endpoint string, out io.Writer, remoteNam func (s *TagStore) pushRepository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, localRepo map[string]string, tag string, sf *streamformatter.StreamFormatter) error { - log.Debugf("Local repo: %s", localRepo) + logrus.Debugf("Local repo: %s", localRepo) out = utils.NewWriteFlusher(out) imgList, tags, err := s.getImageList(localRepo, tag) if err != nil { @@ -214,9 +214,9 @@ func (s *TagStore) pushRepository(r *registry.Session, out io.Writer, out.Write(sf.FormatStatus("", "Sending image list")) imageIndex := s.createImageIndex(imgList, tags) - log.Debugf("Preparing to push %s with the following images and tags", localRepo) + logrus.Debugf("Preparing to push %s with the following images and tags", localRepo) for _, data := range imageIndex { - log.Debugf("Pushing ID: %s with Tag: %s", data.ID, data.Tag) + logrus.Debugf("Pushing ID: %s with Tag: %s", data.ID, data.Tag) } // Register all the images in a repository with the registry // If an image is not in this list it will not be associated with the repository @@ -267,7 +267,7 @@ func (s *TagStore) pushImage(r *registry.Session, out io.Writer, imgID, ep strin defer os.RemoveAll(layerData.Name()) // Send the layer - log.Debugf("rendered layer for %s of [%d] size", imgData.ID, layerData.Size) + logrus.Debugf("rendered layer for %s of [%d] size", imgData.ID, layerData.Size) checksum, checksumPayload, err := r.PushImageLayerRegistry(imgData.ID, progressreader.New(progressreader.Config{ @@ -297,7 +297,7 @@ func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, o endpoint, err := r.V2RegistryEndpoint(repoInfo.Index) if err != nil { if repoInfo.Index.Official { - log.Debugf("Unable to push to V2 registry, falling back to v1: %s", err) + logrus.Debugf("Unable to push to V2 registry, falling back to v1: %s", err) return ErrV2RegistryUnavailable } return fmt.Errorf("error getting registry endpoint: %s", err) @@ -317,7 +317,7 @@ func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, o } for _, tag := range tags { - log.Debugf("Pushing repository: %s:%s", repoInfo.CanonicalName, tag) + logrus.Debugf("Pushing repository: %s:%s", repoInfo.CanonicalName, tag) layerId, exists := localRepo[tag] if !exists { @@ -358,7 +358,7 @@ func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, o // Schema version 1 requires layer ordering from top to root for i, layer := range layers { - log.Debugf("Pushing layer: %s", layer.ID) + logrus.Debugf("Pushing layer: %s", layer.ID) if layer.Config != nil && metadata.Image != layer.ID { err = runconfig.Merge(&metadata, layer.Config) @@ -411,7 +411,7 @@ func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, o return fmt.Errorf("invalid manifest: %s", err) } - log.Debugf("Pushing %s:%s to v2 repository", repoInfo.LocalName, tag) + logrus.Debugf("Pushing %s:%s to v2 repository", repoInfo.LocalName, tag) mBytes, err := json.MarshalIndent(m, "", " ") if err != nil { return err @@ -429,7 +429,7 @@ func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, o if err != nil { return err } - log.Infof("Signed manifest for %s:%s using daemon's key: %s", repoInfo.LocalName, tag, s.trustKey.KeyID()) + logrus.Infof("Signed manifest for %s:%s using daemon's key: %s", repoInfo.LocalName, tag, s.trustKey.KeyID()) // push the manifest digest, err := r.PutV2ImageManifest(endpoint, repoInfo.RemoteName, tag, signedBody, mBytes, auth) @@ -473,7 +473,7 @@ func (s *TagStore) pushV2Image(r *registry.Session, img *image.Image, endpoint * dgst := digest.NewDigest("sha256", h) // Send the layer - log.Debugf("rendered layer for %s of [%d] size", img.ID, size) + logrus.Debugf("rendered layer for %s of [%d] size", img.ID, size) if err := r.PutV2ImageBlob(endpoint, imageName, dgst.Algorithm(), dgst.Hex(), progressreader.New(progressreader.Config{ diff --git a/graph/service.go b/graph/service.go index 03ae8f4c00c9fce70f3be0a40f0a338ca56a696c..c6d6a0872710aa096bad1249d8993b74aedb61ce 100644 --- a/graph/service.go +++ b/graph/service.go @@ -4,7 +4,7 @@ import ( "fmt" "io" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/docker/image" ) @@ -174,7 +174,7 @@ func (s *TagStore) CmdTarLayer(job *engine.Job) error { if err != nil { return err } - log.Debugf("rendered layer for %s of [%d] size", image.ID, written) + logrus.Debugf("rendered layer for %s of [%d] size", image.ID, written) return nil } return fmt.Errorf("No such image: %s", name) diff --git a/integration/commands_test.go b/integration/commands_test.go index f748efd6d629b592a7e89b750a56e53524b014dd..97a927b8bf3b6d00f8ecd2a4779748db923dacbc 100644 --- a/integration/commands_test.go +++ b/integration/commands_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/api/client" "github.com/docker/docker/daemon" "github.com/docker/docker/pkg/stringid" @@ -337,7 +337,7 @@ func TestAttachDisconnect(t *testing.T) { go func() { // Start a process in daemon mode if err := cli.CmdRun("-d", "-i", unitTestImageID, "/bin/cat"); err != nil { - log.Debugf("Error CmdRun: %s", err) + logrus.Debugf("Error CmdRun: %s", err) } }() diff --git a/integration/runtime_test.go b/integration/runtime_test.go index 4c16327714c388b07a6b718774fdfa67458408b7..07d9de7c62a162e7852bdeea9c22c5649057f7dd 100644 --- a/integration/runtime_test.go +++ b/integration/runtime_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/engine" @@ -94,23 +94,23 @@ func init() { } if uid := syscall.Geteuid(); uid != 0 { - log.Fatalf("docker tests need to be run as root") + logrus.Fatalf("docker tests need to be run as root") } // Copy dockerinit into our current testing directory, if provided (so we can test a separate dockerinit binary) if dockerinit := os.Getenv("TEST_DOCKERINIT_PATH"); dockerinit != "" { src, err := os.Open(dockerinit) if err != nil { - log.Fatalf("Unable to open TEST_DOCKERINIT_PATH: %s", err) + logrus.Fatalf("Unable to open TEST_DOCKERINIT_PATH: %s", err) } defer src.Close() dst, err := os.OpenFile(filepath.Join(filepath.Dir(utils.SelfPath()), "dockerinit"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0555) if err != nil { - log.Fatalf("Unable to create dockerinit in test directory: %s", err) + logrus.Fatalf("Unable to create dockerinit in test directory: %s", err) } defer dst.Close() if _, err := io.Copy(dst, src); err != nil { - log.Fatalf("Unable to copy dockerinit to TEST_DOCKERINIT_PATH: %s", err) + logrus.Fatalf("Unable to copy dockerinit to TEST_DOCKERINIT_PATH: %s", err) } dst.Close() src.Close() @@ -137,14 +137,14 @@ func setupBaseImage() { job = eng.Job("pull", unitTestImageName) job.Stdout.Add(ioutils.NopWriteCloser(os.Stdout)) if err := job.Run(); err != nil { - log.Fatalf("Unable to pull the test image: %s", err) + logrus.Fatalf("Unable to pull the test image: %s", err) } } } func spawnGlobalDaemon() { if globalDaemon != nil { - log.Debugf("Global daemon already exists. Skipping.") + logrus.Debugf("Global daemon already exists. Skipping.") return } t := std_log.New(os.Stderr, "", 0) @@ -154,7 +154,7 @@ func spawnGlobalDaemon() { // Spawn a Daemon go func() { - log.Debugf("Spawning global daemon for integration tests") + logrus.Debugf("Spawning global daemon for integration tests") listenURL := &url.URL{ Scheme: testDaemonProto, Host: testDaemonAddr, @@ -162,7 +162,7 @@ func spawnGlobalDaemon() { job := eng.Job("serveapi", listenURL.String()) job.SetenvBool("Logging", true) if err := job.Run(); err != nil { - log.Fatalf("Unable to spawn the test daemon: %s", err) + logrus.Fatalf("Unable to spawn the test daemon: %s", err) } }() @@ -171,7 +171,7 @@ func spawnGlobalDaemon() { time.Sleep(time.Second) if err := eng.Job("acceptconnections").Run(); err != nil { - log.Fatalf("Unable to accept connections for test api: %s", err) + logrus.Fatalf("Unable to accept connections for test api: %s", err) } } @@ -204,7 +204,7 @@ func spawnHttpsDaemon(addr, cacert, cert, key string) *engine.Engine { // Spawn a Daemon go func() { - log.Debugf("Spawning https daemon for integration tests") + logrus.Debugf("Spawning https daemon for integration tests") listenURL := &url.URL{ Scheme: testDaemonHttpsProto, Host: addr, @@ -217,7 +217,7 @@ func spawnHttpsDaemon(addr, cacert, cert, key string) *engine.Engine { job.Setenv("TlsCert", cert) job.Setenv("TlsKey", key) if err := job.Run(); err != nil { - log.Fatalf("Unable to spawn the test daemon: %s", err) + logrus.Fatalf("Unable to spawn the test daemon: %s", err) } }() @@ -225,7 +225,7 @@ func spawnHttpsDaemon(addr, cacert, cert, key string) *engine.Engine { time.Sleep(time.Second) if err := eng.Job("acceptconnections").Run(); err != nil { - log.Fatalf("Unable to accept connections for test api: %s", err) + logrus.Fatalf("Unable to accept connections for test api: %s", err) } return eng } @@ -235,14 +235,14 @@ func spawnHttpsDaemon(addr, cacert, cert, key string) *engine.Engine { func GetTestImage(daemon *daemon.Daemon) *image.Image { imgs, err := daemon.Graph().Map() if err != nil { - log.Fatalf("Unable to get the test image: %s", err) + logrus.Fatalf("Unable to get the test image: %s", err) } for _, image := range imgs { if image.ID == unitTestImageID { return image } } - log.Fatalf("Test image %v not found in %s: %s", unitTestImageID, daemon.Graph().Root, imgs) + logrus.Fatalf("Test image %v not found in %s: %s", unitTestImageID, daemon.Graph().Root, imgs) return nil } @@ -707,9 +707,9 @@ func TestRandomContainerName(t *testing.T) { } if c, err := daemon.Get(container.Name); err != nil { - log.Fatalf("Could not lookup container %s by its name", container.Name) + logrus.Fatalf("Could not lookup container %s by its name", container.Name) } else if c.ID != containerID { - log.Fatalf("Looking up container name %s returned id %s instead of %s", container.Name, c.ID, containerID) + logrus.Fatalf("Looking up container name %s returned id %s instead of %s", container.Name, c.ID, containerID) } } diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index bfa6e18462f6f0eff380409a17e045cf3c4b6c54..36425f70a50f8845521a7cb21b285632e549668b 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -18,7 +18,7 @@ import ( "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/promise" @@ -78,7 +78,7 @@ func DetectCompression(source []byte) Compression { Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}, } { if len(source) < len(m) { - log.Debugf("Len too short") + logrus.Debugf("Len too short") continue } if bytes.Compare(m, source[:len(m)]) == 0 { @@ -331,7 +331,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L } case tar.TypeXGlobalHeader: - log.Debugf("PAX Global Extended Headers found and ignored") + logrus.Debugf("PAX Global Extended Headers found and ignored") return nil default: @@ -426,7 +426,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) for _, include := range options.IncludeFiles { filepath.Walk(filepath.Join(srcPath, include), func(filePath string, f os.FileInfo, err error) error { if err != nil { - log.Debugf("Tar: Can't stat file %s to tar: %s", srcPath, err) + logrus.Debugf("Tar: Can't stat file %s to tar: %s", srcPath, err) return nil } @@ -447,7 +447,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) if include != relFilePath { skip, err = fileutils.Matches(relFilePath, options.ExcludePatterns) if err != nil { - log.Debugf("Error matching %s", relFilePath, err) + logrus.Debugf("Error matching %s", relFilePath, err) return err } } @@ -474,7 +474,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) } if err := ta.addTarFile(filePath, relFilePath); err != nil { - log.Debugf("Can't add file %s to tar: %s", filePath, err) + logrus.Debugf("Can't add file %s to tar: %s", filePath, err) } return nil }) @@ -482,13 +482,13 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error) // Make sure to check the error on Close. if err := ta.TarWriter.Close(); err != nil { - log.Debugf("Can't close tar writer: %s", err) + logrus.Debugf("Can't close tar writer: %s", err) } if err := compressWriter.Close(); err != nil { - log.Debugf("Can't close compress writer: %s", err) + logrus.Debugf("Can't close compress writer: %s", err) } if err := pipeWriter.Close(); err != nil { - log.Debugf("Can't close pipe writer: %s", err) + logrus.Debugf("Can't close pipe writer: %s", err) } }() @@ -606,7 +606,7 @@ func Untar(archive io.Reader, dest string, options *TarOptions) error { } func (archiver *Archiver) TarUntar(src, dst string) error { - log.Debugf("TarUntar(%s %s)", src, dst) + logrus.Debugf("TarUntar(%s %s)", src, dst) archive, err := TarWithOptions(src, &TarOptions{Compression: Uncompressed}) if err != nil { return err @@ -648,11 +648,11 @@ func (archiver *Archiver) CopyWithTar(src, dst string) error { return archiver.CopyFileWithTar(src, dst) } // Create dst, copy src's content into it - log.Debugf("Creating dest directory: %s", dst) + logrus.Debugf("Creating dest directory: %s", dst) if err := os.MkdirAll(dst, 0755); err != nil && !os.IsExist(err) { return err } - log.Debugf("Calling TarUntar(%s, %s)", src, dst) + logrus.Debugf("Calling TarUntar(%s, %s)", src, dst) return archiver.TarUntar(src, dst) } @@ -665,7 +665,7 @@ func CopyWithTar(src, dst string) error { } func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) { - log.Debugf("CopyFileWithTar(%s, %s)", src, dst) + logrus.Debugf("CopyFileWithTar(%s, %s)", src, dst) srcSt, err := os.Stat(src) if err != nil { return err diff --git a/pkg/archive/changes.go b/pkg/archive/changes.go index 96aff36a3a415e34e89196c8ce226628ab4d3c9a..06fad8eb4f77fa767429a9ce0fc07efc7ab1155d 100644 --- a/pkg/archive/changes.go +++ b/pkg/archive/changes.go @@ -13,7 +13,7 @@ import ( "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/system" ) @@ -401,22 +401,22 @@ func ExportChanges(dir string, changes []Change) (Archive, error) { ChangeTime: timestamp, } if err := ta.TarWriter.WriteHeader(hdr); err != nil { - log.Debugf("Can't write whiteout header: %s", err) + logrus.Debugf("Can't write whiteout header: %s", err) } } else { path := filepath.Join(dir, change.Path) if err := ta.addTarFile(path, change.Path[1:]); err != nil { - log.Debugf("Can't add file %s to tar: %s", path, err) + logrus.Debugf("Can't add file %s to tar: %s", path, err) } } } // Make sure to check the error on Close. if err := ta.TarWriter.Close(); err != nil { - log.Debugf("Can't close layer: %s", err) + logrus.Debugf("Can't close layer: %s", err) } if err := writer.Close(); err != nil { - log.Debugf("failed close Changes writer: %s", err) + logrus.Debugf("failed close Changes writer: %s", err) } }() return reader, nil diff --git a/pkg/broadcastwriter/broadcastwriter.go b/pkg/broadcastwriter/broadcastwriter.go index 232cf3dfc801ce89f32ff95990444deb9595b2b7..1d3c3c5f15c6e72c531055962af527b7df2a5cd2 100644 --- a/pkg/broadcastwriter/broadcastwriter.go +++ b/pkg/broadcastwriter/broadcastwriter.go @@ -6,7 +6,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/jsonlog" ) @@ -61,7 +61,7 @@ func (w *BroadcastWriter) Write(p []byte) (n int, err error) { jsonLog := jsonlog.JSONLog{Log: line, Stream: stream, Created: created} err = jsonLog.MarshalJSONBuf(w.jsLogBuf) if err != nil { - log.Errorf("Error making JSON log line: %s", err) + logrus.Errorf("Error making JSON log line: %s", err) continue } w.jsLogBuf.WriteByte('\n') diff --git a/pkg/devicemapper/attach_loopback.go b/pkg/devicemapper/attach_loopback.go index d39cbc6cf5efdd3ac06a191b62497639a21c68bd..424a974685b849ff9b9522c981d4a28096d543d8 100644 --- a/pkg/devicemapper/attach_loopback.go +++ b/pkg/devicemapper/attach_loopback.go @@ -7,7 +7,7 @@ import ( "os" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) func stringToLoopName(src string) [LoNameSize]uint8 { @@ -39,20 +39,20 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil fi, err := os.Stat(target) if err != nil { if os.IsNotExist(err) { - log.Errorf("There are no more loopback devices available.") + logrus.Errorf("There are no more loopback devices available.") } return nil, ErrAttachLoopbackDevice } if fi.Mode()&os.ModeDevice != os.ModeDevice { - log.Errorf("Loopback device %s is not a block device.", target) + logrus.Errorf("Loopback device %s is not a block device.", target) continue } // OpenFile adds O_CLOEXEC loopFile, err = os.OpenFile(target, os.O_RDWR, 0644) if err != nil { - log.Errorf("Error opening loopback device: %s", err) + logrus.Errorf("Error opening loopback device: %s", err) return nil, ErrAttachLoopbackDevice } @@ -62,7 +62,7 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil // If the error is EBUSY, then try the next loopback if err != syscall.EBUSY { - log.Errorf("Cannot set up loopback device %s: %s", target, err) + logrus.Errorf("Cannot set up loopback device %s: %s", target, err) return nil, ErrAttachLoopbackDevice } @@ -75,7 +75,7 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil // This can't happen, but let's be sure if loopFile == nil { - log.Errorf("Unreachable code reached! Error attaching %s to a loopback device.", sparseFile.Name()) + logrus.Errorf("Unreachable code reached! Error attaching %s to a loopback device.", sparseFile.Name()) return nil, ErrAttachLoopbackDevice } @@ -91,13 +91,13 @@ func AttachLoopDevice(sparseName string) (loop *os.File, err error) { // loopback from index 0. startIndex, err := getNextFreeLoopbackIndex() if err != nil { - log.Debugf("Error retrieving the next available loopback: %s", err) + logrus.Debugf("Error retrieving the next available loopback: %s", err) } // OpenFile adds O_CLOEXEC sparseFile, err := os.OpenFile(sparseName, os.O_RDWR, 0644) if err != nil { - log.Errorf("Error opening sparse file %s: %s", sparseName, err) + logrus.Errorf("Error opening sparse file %s: %s", sparseName, err) return nil, ErrAttachLoopbackDevice } defer sparseFile.Close() @@ -115,11 +115,11 @@ func AttachLoopDevice(sparseName string) (loop *os.File, err error) { } if err := ioctlLoopSetStatus64(loopFile.Fd(), loopInfo); err != nil { - log.Errorf("Cannot set up loopback device info: %s", err) + logrus.Errorf("Cannot set up loopback device info: %s", err) // If the call failed, then free the loopback device if err := ioctlLoopClrFd(loopFile.Fd()); err != nil { - log.Errorf("Error while cleaning up the loopback device") + logrus.Errorf("Error while cleaning up the loopback device") } loopFile.Close() return nil, ErrAttachLoopbackDevice diff --git a/pkg/devicemapper/devmapper.go b/pkg/devicemapper/devmapper.go index 1d45d05884dc54e5d31b721aaddfe48d41de39c3..ec9ff1c8fe5d0cb1012b7c09c891aa583ce5e0e0 100644 --- a/pkg/devicemapper/devmapper.go +++ b/pkg/devicemapper/devmapper.go @@ -9,7 +9,7 @@ import ( "runtime" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) type DevmapperLogger interface { @@ -237,7 +237,7 @@ func (t *Task) GetNextTarget(next uintptr) (nextPtr uintptr, start uint64, func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) { loopInfo, err := ioctlLoopGetStatus64(file.Fd()) if err != nil { - log.Errorf("Error get loopback backing file: %s", err) + logrus.Errorf("Error get loopback backing file: %s", err) return 0, 0, ErrGetLoopbackBackingFile } return loopInfo.loDevice, loopInfo.loInode, nil @@ -245,7 +245,7 @@ func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) { func LoopbackSetCapacity(file *os.File) error { if err := ioctlLoopSetCapacity(file.Fd(), 0); err != nil { - log.Errorf("Error loopbackSetCapacity: %s", err) + logrus.Errorf("Error loopbackSetCapacity: %s", err) return ErrLoopbackSetCapacity } return nil @@ -285,7 +285,7 @@ func FindLoopDeviceFor(file *os.File) *os.File { func UdevWait(cookie uint) error { if res := DmUdevWait(cookie); res != 1 { - log.Debugf("Failed to wait on udev cookie %d", cookie) + logrus.Debugf("Failed to wait on udev cookie %d", cookie) return ErrUdevWait } return nil @@ -305,7 +305,7 @@ func LogInit(logger DevmapperLogger) { func SetDevDir(dir string) error { if res := DmSetDevDir(dir); res != 1 { - log.Debugf("Error dm_set_dev_dir") + logrus.Debugf("Error dm_set_dev_dir") return ErrSetDevDir } return nil @@ -348,8 +348,8 @@ func CookieSupported() bool { // Useful helper for cleanup func RemoveDevice(name string) error { - log.Debugf("[devmapper] RemoveDevice START(%s)", name) - defer log.Debugf("[devmapper] RemoveDevice END(%s)", name) + logrus.Debugf("[devmapper] RemoveDevice START(%s)", name) + defer logrus.Debugf("[devmapper] RemoveDevice END(%s)", name) task, err := TaskCreateNamed(DeviceRemove, name) if task == nil { return err @@ -375,7 +375,7 @@ func RemoveDevice(name string) error { func GetBlockDeviceSize(file *os.File) (uint64, error) { size, err := ioctlBlkGetSize64(file.Fd()) if err != nil { - log.Errorf("Error getblockdevicesize: %s", err) + logrus.Errorf("Error getblockdevicesize: %s", err) return 0, ErrGetBlockSize } return uint64(size), nil @@ -494,21 +494,21 @@ func GetDriverVersion() (string, error) { func GetStatus(name string) (uint64, uint64, string, string, error) { task, err := TaskCreateNamed(DeviceStatus, name) if task == nil { - log.Debugf("GetStatus: Error TaskCreateNamed: %s", err) + logrus.Debugf("GetStatus: Error TaskCreateNamed: %s", err) return 0, 0, "", "", err } if err := task.Run(); err != nil { - log.Debugf("GetStatus: Error Run: %s", err) + logrus.Debugf("GetStatus: Error Run: %s", err) return 0, 0, "", "", err } devinfo, err := task.GetInfo() if err != nil { - log.Debugf("GetStatus: Error GetInfo: %s", err) + logrus.Debugf("GetStatus: Error GetInfo: %s", err) return 0, 0, "", "", err } if devinfo.Exists == 0 { - log.Debugf("GetStatus: Non existing device %s", name) + logrus.Debugf("GetStatus: Non existing device %s", name) return 0, 0, "", "", fmt.Errorf("Non existing device %s", name) } @@ -567,7 +567,7 @@ func ResumeDevice(name string) error { } func CreateDevice(poolName string, deviceId int) error { - log.Debugf("[devmapper] CreateDevice(poolName=%v, deviceId=%v)", poolName, deviceId) + logrus.Debugf("[devmapper] CreateDevice(poolName=%v, deviceId=%v)", poolName, deviceId) task, err := TaskCreateNamed(DeviceTargetMsg, poolName) if task == nil { return err diff --git a/pkg/fileutils/fileutils.go b/pkg/fileutils/fileutils.go index 4e4a91b91aeb741b9b3c1408139471ab615cd35b..64442e40fe7656120dc2fc87d96ee9a5b6d7f660 100644 --- a/pkg/fileutils/fileutils.go +++ b/pkg/fileutils/fileutils.go @@ -1,7 +1,7 @@ package fileutils import ( - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "path/filepath" ) @@ -10,15 +10,15 @@ func Matches(relFilePath string, patterns []string) (bool, error) { for _, exclude := range patterns { matched, err := filepath.Match(exclude, relFilePath) if err != nil { - log.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude) + logrus.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude) return false, err } if matched { if filepath.Clean(relFilePath) == "." { - log.Errorf("Can't exclude whole path, excluding pattern: %s", exclude) + logrus.Errorf("Can't exclude whole path, excluding pattern: %s", exclude) continue } - log.Debugf("Skipping excluded path: %s", relFilePath) + logrus.Debugf("Skipping excluded path: %s", relFilePath) return true, nil } } diff --git a/pkg/httputils/resumablerequestreader.go b/pkg/httputils/resumablerequestreader.go index 10edd43a9828ed77557e2d5a3db5b1f40149fabd..f690d0e0e2720504a9bfbe995fa1000722bc3c57 100644 --- a/pkg/httputils/resumablerequestreader.go +++ b/pkg/httputils/resumablerequestreader.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) type resumableRequestReader struct { @@ -72,7 +72,7 @@ func (r *resumableRequestReader) Read(p []byte) (n int, err error) { r.cleanUpResponse() } if err != nil && err != io.EOF { - log.Infof("encountered error during pull and clearing it before resume: %s", err) + logrus.Infof("encountered error during pull and clearing it before resume: %s", err) err = nil } return n, err diff --git a/pkg/iptables/iptables.go b/pkg/iptables/iptables.go index 3e083a43adc03bd5b557db3204eea43bc638a600..ec20557871bd8c942c0081eceaae527a0916e480 100644 --- a/pkg/iptables/iptables.go +++ b/pkg/iptables/iptables.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) type Action string @@ -283,7 +283,7 @@ func Raw(args ...string) ([]byte, error) { args = append([]string{"--wait"}, args...) } - log.Debugf("%s, %v", iptablesPath, args) + logrus.Debugf("%s, %v", iptablesPath, args) output, err := exec.Command(iptablesPath, args...).CombinedOutput() if err != nil { diff --git a/pkg/jsonlog/jsonlog.go b/pkg/jsonlog/jsonlog.go index e2c2a2cab673451daa66196e77c084292ccd75f9..261c64cdc3ad6e73492a5b9535b9ef86eae3bb94 100644 --- a/pkg/jsonlog/jsonlog.go +++ b/pkg/jsonlog/jsonlog.go @@ -6,7 +6,7 @@ import ( "io" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) type JSONLog struct { @@ -39,7 +39,7 @@ func WriteLog(src io.Reader, dst io.Writer, format string) error { if err := dec.Decode(l); err == io.EOF { return nil } else if err != nil { - log.Printf("Error streaming logs: %s", err) + logrus.Printf("Error streaming logs: %s", err) return err } line, err := l.Format(format) diff --git a/pkg/proxy/tcp_proxy.go b/pkg/proxy/tcp_proxy.go index eacf1427a3cd4cae5a9a87ac237dd4ab16b1f86b..9942e6d901a199b58e775291a9d9293d8e14e419 100644 --- a/pkg/proxy/tcp_proxy.go +++ b/pkg/proxy/tcp_proxy.go @@ -5,7 +5,7 @@ import ( "net" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) type TCPProxy struct { @@ -31,7 +31,7 @@ func NewTCPProxy(frontendAddr, backendAddr *net.TCPAddr) (*TCPProxy, error) { func (proxy *TCPProxy) clientLoop(client *net.TCPConn, quit chan bool) { backend, err := net.DialTCP("tcp", nil, proxy.backendAddr) if err != nil { - log.Printf("Can't forward traffic to backend tcp/%v: %s\n", proxy.backendAddr, err) + logrus.Printf("Can't forward traffic to backend tcp/%v: %s\n", proxy.backendAddr, err) client.Close() return } @@ -78,7 +78,7 @@ func (proxy *TCPProxy) Run() { for { client, err := proxy.listener.Accept() if err != nil { - log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) + logrus.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) return } go proxy.clientLoop(client.(*net.TCPConn), quit) diff --git a/pkg/proxy/udp_proxy.go b/pkg/proxy/udp_proxy.go index a3fcf116e322a90b576b81ec16a0eee64ed1c2fd..2a073dfe8e0b4b3de05f2f748273a68faa5039df 100644 --- a/pkg/proxy/udp_proxy.go +++ b/pkg/proxy/udp_proxy.go @@ -8,7 +8,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) const ( @@ -105,7 +105,7 @@ func (proxy *UDPProxy) Run() { // ECONNREFUSED like Read do (see comment in // UDPProxy.replyLoop) if !isClosedError(err) { - log.Printf("Stopping proxy on udp/%v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) + logrus.Printf("Stopping proxy on udp/%v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) } break } @@ -116,7 +116,7 @@ func (proxy *UDPProxy) Run() { if !hit { proxyConn, err = net.DialUDP("udp", nil, proxy.backendAddr) if err != nil { - log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err) + logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err) proxy.connTrackLock.Unlock() continue } @@ -127,7 +127,7 @@ func (proxy *UDPProxy) Run() { for i := 0; i != read; { written, err := proxyConn.Write(readBuf[i:read]) if err != nil { - log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err) + logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err) break } i += written diff --git a/pkg/resolvconf/resolvconf.go b/pkg/resolvconf/resolvconf.go index d6f0f7a9549e59dd71190e5ae8febcda6b61f5a7..d7d53e16d010fad25e53264324c4fd60dfce6cd2 100644 --- a/pkg/resolvconf/resolvconf.go +++ b/pkg/resolvconf/resolvconf.go @@ -8,7 +8,7 @@ import ( "strings" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/utils" ) @@ -99,10 +99,10 @@ func FilterResolvDns(resolvConf []byte, ipv6Enabled bool) ([]byte, bool) { // if the resulting resolvConf has no more nameservers defined, add appropriate // default DNS servers for IPv4 and (optionally) IPv6 if len(GetNameservers(cleanedResolvConf)) == 0 { - log.Infof("No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : %v", defaultIPv4Dns) + logrus.Infof("No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : %v", defaultIPv4Dns) dns := defaultIPv4Dns if ipv6Enabled { - log.Infof("IPv6 enabled; Adding default IPv6 external servers : %v", defaultIPv6Dns) + logrus.Infof("IPv6 enabled; Adding default IPv6 external servers : %v", defaultIPv6Dns) dns = append(dns, defaultIPv6Dns...) } cleanedResolvConf = append(cleanedResolvConf, []byte("\n"+strings.Join(dns, "\n"))...) diff --git a/pkg/signal/trap.go b/pkg/signal/trap.go index 78a709b30a13356092cbfeaf96206d9a4c4b7a8d..7469dbcc2103a2b86bd4da730b91c223e01b39f2 100644 --- a/pkg/signal/trap.go +++ b/pkg/signal/trap.go @@ -6,7 +6,7 @@ import ( "sync/atomic" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) // Trap sets up a simplified signal "trap", appropriate for common @@ -29,7 +29,7 @@ func Trap(cleanup func()) { interruptCount := uint32(0) for sig := range c { go func(sig os.Signal) { - log.Infof("Received signal '%v', starting shutdown of docker...", sig) + logrus.Infof("Received signal '%v', starting shutdown of docker...", sig) switch sig { case os.Interrupt, syscall.SIGTERM: // If the user really wants to interrupt, let him do so. @@ -43,7 +43,7 @@ func Trap(cleanup func()) { return } } else { - log.Infof("Force shutdown of docker, interrupting cleanup") + logrus.Infof("Force shutdown of docker, interrupting cleanup") } case syscall.SIGQUIT: } diff --git a/pkg/stdcopy/stdcopy.go b/pkg/stdcopy/stdcopy.go index a61779ce5371f354edca335928a48e7a6e1da821..ccf1d9dbabad0beb211cd5373c8d298ff26c702a 100644 --- a/pkg/stdcopy/stdcopy.go +++ b/pkg/stdcopy/stdcopy.go @@ -5,7 +5,7 @@ import ( "errors" "io" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) const ( @@ -95,13 +95,13 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) nr += nr2 if er == io.EOF { if nr < StdWriterPrefixLen { - log.Debugf("Corrupted prefix: %v", buf[:nr]) + logrus.Debugf("Corrupted prefix: %v", buf[:nr]) return written, nil } break } if er != nil { - log.Debugf("Error reading header: %s", er) + logrus.Debugf("Error reading header: %s", er) return 0, er } } @@ -117,18 +117,18 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) // Write on stderr out = dsterr default: - log.Debugf("Error selecting output fd: (%d)", buf[StdWriterFdIndex]) + logrus.Debugf("Error selecting output fd: (%d)", buf[StdWriterFdIndex]) return 0, ErrInvalidStdHeader } // Retrieve the size of the frame frameSize = int(binary.BigEndian.Uint32(buf[StdWriterSizeIndex : StdWriterSizeIndex+4])) - log.Debugf("framesize: %d", frameSize) + logrus.Debugf("framesize: %d", frameSize) // Check if the buffer is big enough to read the frame. // Extend it if necessary. if frameSize+StdWriterPrefixLen > bufLen { - log.Debugf("Extending buffer cap by %d (was %d)", frameSize+StdWriterPrefixLen-bufLen+1, len(buf)) + logrus.Debugf("Extending buffer cap by %d (was %d)", frameSize+StdWriterPrefixLen-bufLen+1, len(buf)) buf = append(buf, make([]byte, frameSize+StdWriterPrefixLen-bufLen+1)...) bufLen = len(buf) } @@ -140,13 +140,13 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) nr += nr2 if er == io.EOF { if nr < frameSize+StdWriterPrefixLen { - log.Debugf("Corrupted frame: %v", buf[StdWriterPrefixLen:nr]) + logrus.Debugf("Corrupted frame: %v", buf[StdWriterPrefixLen:nr]) return written, nil } break } if er != nil { - log.Debugf("Error reading frame: %s", er) + logrus.Debugf("Error reading frame: %s", er) return 0, er } } @@ -154,12 +154,12 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error) // Write the retrieved frame (without header) nw, ew = out.Write(buf[StdWriterPrefixLen : frameSize+StdWriterPrefixLen]) if ew != nil { - log.Debugf("Error writing frame: %s", ew) + logrus.Debugf("Error writing frame: %s", ew) return 0, ew } // If the frame has not been fully written: error if nw != frameSize { - log.Debugf("Error Short Write: (%d on %d)", nw, frameSize) + logrus.Debugf("Error Short Write: (%d on %d)", nw, frameSize) return 0, io.ErrShortWrite } written += int64(nw) diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index 1d540d2e7df28f9bc66f2c287dfd9f657763bd96..506124e74e739c9999ac5386e396f6eca89a1c7d 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -5,7 +5,7 @@ import ( "os" "path" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/libcontainer/cgroups" ) @@ -20,20 +20,20 @@ func New(quiet bool) *SysInfo { sysInfo := &SysInfo{} if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil { if !quiet { - log.Warnf("%s", err) + logrus.Warnf("%s", err) } } else { _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes")) _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) sysInfo.MemoryLimit = err1 == nil && err2 == nil if !sysInfo.MemoryLimit && !quiet { - log.Warnf("Your kernel does not support cgroup memory limit.") + logrus.Warnf("Your kernel does not support cgroup memory limit.") } _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")) sysInfo.SwapLimit = err == nil if !sysInfo.SwapLimit && !quiet { - log.Warnf("Your kernel does not support cgroup swap limit.") + logrus.Warnf("Your kernel does not support cgroup swap limit.") } } diff --git a/registry/auth.go b/registry/auth.go index 4baf114c6cf969bac28b571353bcf745f4cba940..eaecc0f267afee4fcfe528b3297db1e56032b41a 100644 --- a/registry/auth.go +++ b/registry/auth.go @@ -13,7 +13,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/utils" ) @@ -66,7 +66,7 @@ func (auth *RequestAuthorization) getToken() (string, error) { defer auth.tokenLock.Unlock() now := time.Now() if now.Before(auth.tokenExpiration) { - log.Debugf("Using cached token for %s", auth.authConfig.Username) + logrus.Debugf("Using cached token for %s", auth.authConfig.Username) return auth.tokenCache, nil } @@ -78,7 +78,7 @@ func (auth *RequestAuthorization) getToken() (string, error) { case "basic": // no token necessary case "bearer": - log.Debugf("Getting bearer token with %s for %s", challenge.Parameters, auth.authConfig.Username) + logrus.Debugf("Getting bearer token with %s for %s", challenge.Parameters, auth.authConfig.Username) params := map[string]string{} for k, v := range challenge.Parameters { params[k] = v @@ -93,7 +93,7 @@ func (auth *RequestAuthorization) getToken() (string, error) { return token, nil default: - log.Infof("Unsupported auth scheme: %q", challenge.Scheme) + logrus.Infof("Unsupported auth scheme: %q", challenge.Scheme) } } @@ -245,7 +245,7 @@ func loginV1(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils. serverAddress = authConfig.ServerAddress ) - log.Debugf("attempting v1 login to registry endpoint %s", registryEndpoint) + logrus.Debugf("attempting v1 login to registry endpoint %s", registryEndpoint) if serverAddress == "" { return "", fmt.Errorf("Server Error: Server Address not set.") @@ -349,7 +349,7 @@ func loginV1(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils. // served by the v2 registry service provider. Whether this will be supported in the future // is to be determined. func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.HTTPRequestFactory) (string, error) { - log.Debugf("attempting v2 login to registry endpoint %s", registryEndpoint) + logrus.Debugf("attempting v2 login to registry endpoint %s", registryEndpoint) var ( err error allErrors []error @@ -357,7 +357,7 @@ func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils. ) for _, challenge := range registryEndpoint.AuthChallenges { - log.Debugf("trying %q auth challenge with params %s", challenge.Scheme, challenge.Parameters) + logrus.Debugf("trying %q auth challenge with params %s", challenge.Scheme, challenge.Parameters) switch strings.ToLower(challenge.Scheme) { case "basic": @@ -373,7 +373,7 @@ func loginV2(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils. return "Login Succeeded", nil } - log.Debugf("error trying auth challenge %q: %s", challenge.Scheme, err) + logrus.Debugf("error trying auth challenge %q: %s", challenge.Scheme, err) allErrors = append(allErrors, err) } diff --git a/registry/endpoint.go b/registry/endpoint.go index 59ae4dd5427fd73b2deecab4bdbb7fea769b753a..b883d36d0ca143b77114030d6446bec636531466 100644 --- a/registry/endpoint.go +++ b/registry/endpoint.go @@ -10,7 +10,7 @@ import ( "net/url" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/registry/v2" "github.com/docker/docker/utils" ) @@ -57,7 +57,7 @@ func NewEndpoint(index *IndexInfo) (*Endpoint, error) { } func validateEndpoint(endpoint *Endpoint) error { - log.Debugf("pinging registry endpoint %s", endpoint) + logrus.Debugf("pinging registry endpoint %s", endpoint) // Try HTTPS ping to registry endpoint.URL.Scheme = "https" @@ -69,7 +69,7 @@ func validateEndpoint(endpoint *Endpoint) error { } // If registry is insecure and HTTPS failed, fallback to HTTP. - log.Debugf("Error from registry %q marked as insecure: %v. Insecurely falling back to HTTP", endpoint, err) + logrus.Debugf("Error from registry %q marked as insecure: %v. Insecurely falling back to HTTP", endpoint, err) endpoint.URL.Scheme = "http" var err2 error @@ -163,7 +163,7 @@ func (e *Endpoint) Ping() (RegistryInfo, error) { } func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, error) { - log.Debugf("attempting v1 ping for registry endpoint %s", e) + logrus.Debugf("attempting v1 ping for registry endpoint %s", e) if e.String() == IndexServerAddress() { // Skip the check, we know this one is valid @@ -194,17 +194,17 @@ func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, erro Standalone: true, } if err := json.Unmarshal(jsonString, &info); err != nil { - log.Debugf("Error unmarshalling the _ping RegistryInfo: %s", err) + logrus.Debugf("Error unmarshalling the _ping RegistryInfo: %s", err) // don't stop here. Just assume sane defaults } if hdr := resp.Header.Get("X-Docker-Registry-Version"); hdr != "" { - log.Debugf("Registry version header: '%s'", hdr) + logrus.Debugf("Registry version header: '%s'", hdr) info.Version = hdr } - log.Debugf("RegistryInfo.Version: %q", info.Version) + logrus.Debugf("RegistryInfo.Version: %q", info.Version) standalone := resp.Header.Get("X-Docker-Registry-Standalone") - log.Debugf("Registry standalone header: '%s'", standalone) + logrus.Debugf("Registry standalone header: '%s'", standalone) // Accepted values are "true" (case-insensitive) and "1". if strings.EqualFold(standalone, "true") || standalone == "1" { info.Standalone = true @@ -212,12 +212,12 @@ func (e *Endpoint) pingV1(factory *utils.HTTPRequestFactory) (RegistryInfo, erro // there is a header set, and it is not "true" or "1", so assume fails info.Standalone = false } - log.Debugf("RegistryInfo.Standalone: %t", info.Standalone) + logrus.Debugf("RegistryInfo.Standalone: %t", info.Standalone) return info, nil } func (e *Endpoint) pingV2(factory *utils.HTTPRequestFactory) (RegistryInfo, error) { - log.Debugf("attempting v2 ping for registry endpoint %s", e) + logrus.Debugf("attempting v2 ping for registry endpoint %s", e) req, err := factory.NewRequest("GET", e.Path(""), nil) if err != nil { diff --git a/registry/registry.go b/registry/registry.go index a8bb83318d55c692f3bbd77778bf564538802c3c..163e2de3776ac7c426dcd36990cadd7ac63c4a85 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -13,7 +13,7 @@ import ( "strings" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/timeoutconn" ) @@ -100,7 +100,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur } hostDir := path.Join("/etc/docker/certs.d", req.URL.Host) - log.Debugf("hostDir: %s", hostDir) + logrus.Debugf("hostDir: %s", hostDir) fs, err := ioutil.ReadDir(hostDir) if err != nil && !os.IsNotExist(err) { return nil, nil, err @@ -111,7 +111,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur if pool == nil { pool = x509.NewCertPool() } - log.Debugf("crt: %s", hostDir+"/"+f.Name()) + logrus.Debugf("crt: %s", hostDir+"/"+f.Name()) data, err := ioutil.ReadFile(path.Join(hostDir, f.Name())) if err != nil { return nil, nil, err @@ -121,7 +121,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur if strings.HasSuffix(f.Name(), ".cert") { certName := f.Name() keyName := certName[:len(certName)-5] + ".key" - log.Debugf("cert: %s", hostDir+"/"+f.Name()) + logrus.Debugf("cert: %s", hostDir+"/"+f.Name()) if !hasFile(fs, keyName) { return nil, nil, fmt.Errorf("Missing key %s for certificate %s", keyName, certName) } @@ -134,7 +134,7 @@ func doRequest(req *http.Request, jar http.CookieJar, timeout TimeoutType, secur if strings.HasSuffix(f.Name(), ".key") { keyName := f.Name() certName := keyName[:len(keyName)-4] + ".cert" - log.Debugf("key: %s", hostDir+"/"+f.Name()) + logrus.Debugf("key: %s", hostDir+"/"+f.Name()) if !hasFile(fs, certName) { return nil, nil, fmt.Errorf("Missing certificate %s for key %s", certName, keyName) } diff --git a/registry/registry_mock_test.go b/registry/registry_mock_test.go index 57233d7c79c3d29a0359b126ea82834bdd61c621..82818b41c6228aa7034f7bedd0591db034895e0f 100644 --- a/registry/registry_mock_test.go +++ b/registry/registry_mock_test.go @@ -18,7 +18,7 @@ import ( "github.com/docker/docker/opts" "github.com/gorilla/mux" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) var ( @@ -134,7 +134,7 @@ func init() { func handlerAccessLog(handler http.Handler) http.Handler { logHandler := func(w http.ResponseWriter, r *http.Request) { - log.Debugf("%s \"%s %s\"", r.RemoteAddr, r.Method, r.URL) + logrus.Debugf("%s \"%s %s\"", r.RemoteAddr, r.Method, r.URL) handler.ServeHTTP(w, r) } return http.HandlerFunc(logHandler) @@ -467,7 +467,7 @@ func TestPing(t *testing.T) { * WARNING: Don't push on the repos uncommented, it'll block the tests * func TestWait(t *testing.T) { - log.Println("Test HTTP server ready and waiting:", testHttpServer.URL) + logrus.Println("Test HTTP server ready and waiting:", testHttpServer.URL) c := make(chan int) <-c } diff --git a/registry/service.go b/registry/service.go index 5daacb2b14cfc5c8c64efcd880dfb7eb4b3696b3..f464faabc374db567ca6288ffbbaae040c518e7c 100644 --- a/registry/service.go +++ b/registry/service.go @@ -3,7 +3,7 @@ package registry import ( "fmt" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" ) @@ -62,18 +62,18 @@ func (s *Service) Auth(job *engine.Job) error { } if endpoint, err = NewEndpoint(index); err != nil { - log.Errorf("unable to get new registry endpoint: %s", err) + logrus.Errorf("unable to get new registry endpoint: %s", err) return err } authConfig.ServerAddress = endpoint.String() if status, err = Login(authConfig, endpoint, HTTPRequestFactory(nil)); err != nil { - log.Errorf("unable to login against registry endpoint %s: %s", endpoint, err) + logrus.Errorf("unable to login against registry endpoint %s: %s", endpoint, err) return err } - log.Infof("successful registry login for endpoint %s: %s", endpoint, status) + logrus.Infof("successful registry login for endpoint %s: %s", endpoint, status) job.Printf("%s\n", status) return nil diff --git a/registry/session.go b/registry/session.go index bf04b586d47fcd45da74267b271a0d8d1bd4f8dd..1d70eff9a1184eb56677e9a693fd7bf41b6368c6 100644 --- a/registry/session.go +++ b/registry/session.go @@ -17,7 +17,7 @@ import ( "strings" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/utils" @@ -54,7 +54,7 @@ func NewSession(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, endpo return nil, err } if info.Standalone { - log.Debugf("Endpoint %s is eligible for private registry. Enabling decorator.", r.indexEndpoint.String()) + logrus.Debugf("Endpoint %s is eligible for private registry. Enabling decorator.", r.indexEndpoint.String()) dec := utils.NewHTTPAuthDecorator(authConfig.Username, authConfig.Password) factory.AddDecorator(dec) } @@ -93,7 +93,7 @@ func (r *Session) GetRemoteHistory(imgID, registry string, token []string) ([]st return nil, fmt.Errorf("Error while reading the http response: %s", err) } - log.Debugf("Ancestry: %s", jsonString) + logrus.Debugf("Ancestry: %s", jsonString) history := new([]string) if err := json.Unmarshal(jsonString, history); err != nil { return nil, err @@ -169,7 +169,7 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, im statusCode = 0 res, client, err = r.doRequest(req) if err != nil { - log.Debugf("Error contacting registry: %s", err) + logrus.Debugf("Error contacting registry: %s", err) if res != nil { if res.Body != nil { res.Body.Close() @@ -193,10 +193,10 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, im } if res.Header.Get("Accept-Ranges") == "bytes" && imgSize > 0 { - log.Debugf("server supports resume") + logrus.Debugf("server supports resume") return httputils.ResumableRequestReaderWithInitialResponse(client, req, 5, imgSize, res), nil } - log.Debugf("server doesn't support resume") + logrus.Debugf("server doesn't support resume") return res.Body, nil } @@ -219,7 +219,7 @@ func (r *Session) GetRemoteTags(registries []string, repository string, token [] return nil, err } - log.Debugf("Got status code %d from %s", res.StatusCode, endpoint) + logrus.Debugf("Got status code %d from %s", res.StatusCode, endpoint) defer res.Body.Close() if res.StatusCode != 200 && res.StatusCode != 404 { @@ -259,7 +259,7 @@ func buildEndpointsList(headers []string, indexEp string) ([]string, error) { func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) { repositoryTarget := fmt.Sprintf("%srepositories/%s/images", r.indexEndpoint.VersionString(1), remote) - log.Debugf("[registry] Calling GET %s", repositoryTarget) + logrus.Debugf("[registry] Calling GET %s", repositoryTarget) req, err := r.reqFactory.NewRequest("GET", repositoryTarget, nil) if err != nil { @@ -285,7 +285,7 @@ func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) { } else if res.StatusCode != 200 { errBody, err := ioutil.ReadAll(res.Body) if err != nil { - log.Debugf("Error reading response body: %s", err) + logrus.Debugf("Error reading response body: %s", err) } return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to pull repository %s: %q", res.StatusCode, remote, errBody), res) } @@ -326,7 +326,7 @@ func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) { func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, token []string) error { - log.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/checksum") + logrus.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/checksum") req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgData.ID+"/checksum", nil) if err != nil { @@ -363,7 +363,7 @@ func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, t // Push a local image to the registry func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error { - log.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/json") + logrus.Debugf("[registry] Calling PUT %s", registry+"images/"+imgData.ID+"/json") req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgData.ID+"/json", bytes.NewReader(jsonRaw)) if err != nil { @@ -398,7 +398,7 @@ func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, regist func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string, jsonRaw []byte) (checksum string, checksumPayload string, err error) { - log.Debugf("[registry] Calling PUT %s", registry+"images/"+imgID+"/layer") + logrus.Debugf("[registry] Calling PUT %s", registry+"images/"+imgID+"/layer") tarsumLayer, err := tarsum.NewTarSum(layer, false, tarsum.Version0) if err != nil { @@ -486,8 +486,8 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate suffix = "images" } u := fmt.Sprintf("%srepositories/%s/%s", r.indexEndpoint.VersionString(1), remote, suffix) - log.Debugf("[registry] PUT %s", u) - log.Debugf("Image list pushed to index:\n%s", imgListJSON) + logrus.Debugf("[registry] PUT %s", u) + logrus.Debugf("Image list pushed to index:\n%s", imgListJSON) headers := map[string][]string{ "Content-type": {"application/json"}, "X-Docker-Token": {"true"}, @@ -507,7 +507,7 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate } res.Body.Close() u = res.Header.Get("Location") - log.Debugf("Redirected to %s", u) + logrus.Debugf("Redirected to %s", u) } defer res.Body.Close() @@ -520,13 +520,13 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate if res.StatusCode != 200 && res.StatusCode != 201 { errBody, err := ioutil.ReadAll(res.Body) if err != nil { - log.Debugf("Error reading response body: %s", err) + logrus.Debugf("Error reading response body: %s", err) } return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push repository %s: %q", res.StatusCode, remote, errBody), res) } if res.Header.Get("X-Docker-Token") != "" { tokens = res.Header["X-Docker-Token"] - log.Debugf("Auth token: %v", tokens) + logrus.Debugf("Auth token: %v", tokens) } else { return nil, fmt.Errorf("Index response didn't contain an access token") } @@ -544,7 +544,7 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate if res.StatusCode != 204 { errBody, err := ioutil.ReadAll(res.Body) if err != nil { - log.Debugf("Error reading response body: %s", err) + logrus.Debugf("Error reading response body: %s", err) } return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push checksums %s: %q", res.StatusCode, remote, errBody), res) } @@ -578,7 +578,7 @@ func shouldRedirect(response *http.Response) bool { } func (r *Session) SearchRepositories(term string) (*SearchResults, error) { - log.Debugf("Index server: %s", r.indexEndpoint) + logrus.Debugf("Index server: %s", r.indexEndpoint) u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term) req, err := r.reqFactory.NewRequest("GET", u, nil) if err != nil { diff --git a/registry/session_v2.go b/registry/session_v2.go index 22f39317be251040d2833e38509931deb4056920..a01c8b9ab2441bbc0118175287779f9a4d4061a6 100644 --- a/registry/session_v2.go +++ b/registry/session_v2.go @@ -9,7 +9,7 @@ import ( "net/http" "strconv" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" "github.com/docker/docker/registry/v2" "github.com/docker/docker/utils" @@ -57,7 +57,7 @@ func (r *Session) GetV2Authorization(ep *Endpoint, imageName string, readOnly bo scopes = append(scopes, "push") } - log.Debugf("Getting authorization for %s %s", imageName, scopes) + logrus.Debugf("Getting authorization for %s %s", imageName, scopes) return NewRequestAuthorization(r.GetAuthConfig(true), ep, "repository", imageName, scopes), nil } @@ -75,7 +75,7 @@ func (r *Session) GetV2ImageManifest(ep *Endpoint, imageName, tagName string, au } method := "GET" - log.Debugf("[registry] Calling %q %s", method, routeURL) + logrus.Debugf("[registry] Calling %q %s", method, routeURL) req, err := r.reqFactory.NewRequest(method, routeURL, nil) if err != nil { @@ -116,7 +116,7 @@ func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName, sumType, sum string, } method := "HEAD" - log.Debugf("[registry] Calling %q %s", method, routeURL) + logrus.Debugf("[registry] Calling %q %s", method, routeURL) req, err := r.reqFactory.NewRequest(method, routeURL, nil) if err != nil { @@ -151,7 +151,7 @@ func (r *Session) GetV2ImageBlob(ep *Endpoint, imageName, sumType, sum string, b } method := "GET" - log.Debugf("[registry] Calling %q %s", method, routeURL) + logrus.Debugf("[registry] Calling %q %s", method, routeURL) req, err := r.reqFactory.NewRequest(method, routeURL, nil) if err != nil { return err @@ -182,7 +182,7 @@ func (r *Session) GetV2ImageBlobReader(ep *Endpoint, imageName, sumType, sum str } method := "GET" - log.Debugf("[registry] Calling %q %s", method, routeURL) + logrus.Debugf("[registry] Calling %q %s", method, routeURL) req, err := r.reqFactory.NewRequest(method, routeURL, nil) if err != nil { return nil, 0, err @@ -219,7 +219,7 @@ func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string } method := "PUT" - log.Debugf("[registry] Calling %q %s", method, location) + logrus.Debugf("[registry] Calling %q %s", method, location) req, err := r.reqFactory.NewRequest(method, location, ioutil.NopCloser(blobRdr)) if err != nil { return err @@ -244,7 +244,7 @@ func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string if err != nil { return err } - log.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) + logrus.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) return utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to push %s blob - %s:%s", res.StatusCode, imageName, sumType, sumStr), res) } @@ -258,7 +258,7 @@ func (r *Session) initiateBlobUpload(ep *Endpoint, imageName string, auth *Reque return "", err } - log.Debugf("[registry] Calling %q %s", "POST", routeURL) + logrus.Debugf("[registry] Calling %q %s", "POST", routeURL) req, err := r.reqFactory.NewRequest("POST", routeURL, nil) if err != nil { return "", err @@ -285,7 +285,7 @@ func (r *Session) initiateBlobUpload(ep *Endpoint, imageName string, auth *Reque return "", err } - log.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) + logrus.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) return "", utils.NewHTTPRequestError(fmt.Sprintf("Server error: unexpected %d response status trying to initiate upload of %s", res.StatusCode, imageName), res) } @@ -304,7 +304,7 @@ func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, si } method := "PUT" - log.Debugf("[registry] Calling %q %s", method, routeURL) + logrus.Debugf("[registry] Calling %q %s", method, routeURL) req, err := r.reqFactory.NewRequest(method, routeURL, bytes.NewReader(signedManifest)) if err != nil { return "", err @@ -327,7 +327,7 @@ func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, si if err != nil { return "", err } - log.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) + logrus.Debugf("Unexpected response from server: %q %#v", errBody, res.Header) return "", utils.NewHTTPRequestError(fmt.Sprintf("Server error: %d trying to push %s:%s manifest", res.StatusCode, imageName, tagName), res) } @@ -364,7 +364,7 @@ func (r *Session) GetV2RemoteTags(ep *Endpoint, imageName string, auth *RequestA } method := "GET" - log.Debugf("[registry] Calling %q %s", method, routeURL) + logrus.Debugf("[registry] Calling %q %s", method, routeURL) req, err := r.reqFactory.NewRequest(method, routeURL, nil) if err != nil { diff --git a/runconfig/merge.go b/runconfig/merge.go index 9bbdc6ad25fa58d48d311b2c1e1a180e123d1760..68d3d6ee125e5fb0f1cf569465f83cb7f2153bbb 100644 --- a/runconfig/merge.go +++ b/runconfig/merge.go @@ -3,7 +3,7 @@ package runconfig import ( "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/nat" ) @@ -50,7 +50,7 @@ func Merge(userConf, imageConf *Config) error { } if len(imageConf.PortSpecs) > 0 { // FIXME: I think we can safely remove this. Leaving it for now for the sake of reverse-compat paranoia. - log.Debugf("Migrating image port specs to containter: %s", strings.Join(imageConf.PortSpecs, ", ")) + logrus.Debugf("Migrating image port specs to containter: %s", strings.Join(imageConf.PortSpecs, ", ")) if userConf.ExposedPorts == nil { userConf.ExposedPorts = make(nat.PortSet) } diff --git a/trust/service.go b/trust/service.go index 923537c9cfc539a3d1b23eb8fc1f771e74d04da6..12b96456670258b3ebe2034e8e99e34ce52d9e3f 100644 --- a/trust/service.go +++ b/trust/service.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" "github.com/docker/libtrust" ) @@ -56,7 +56,7 @@ func (t *TrustStore) CmdCheckKey(job *engine.Job) error { return fmt.Errorf("Error verifying key to namespace: %s", namespace) } if !verified { - log.Debugf("Verification failed for %s using key %s", namespace, pk.KeyID()) + logrus.Debugf("Verification failed for %s using key %s", namespace, pk.KeyID()) job.Stdout.Write([]byte("not verified")) } else if t.expiration.Before(time.Now()) { job.Stdout.Write([]byte("expired")) diff --git a/trust/trusts.go b/trust/trusts.go index f5e317e9e36f6ce0ffe973a517c099d5a59e10bf..c4a2f4158b21f420651a4e3f9fec4896c96315ce 100644 --- a/trust/trusts.go +++ b/trust/trusts.go @@ -12,7 +12,7 @@ import ( "sync" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/libtrust/trustgraph" ) @@ -93,7 +93,7 @@ func (t *TrustStore) reload() error { } if len(statements) == 0 { if t.autofetch { - log.Debugf("No grants, fetching") + logrus.Debugf("No grants, fetching") t.fetcher = time.AfterFunc(t.fetchTime, t.fetch) } return nil @@ -106,7 +106,7 @@ func (t *TrustStore) reload() error { t.expiration = expiration t.graph = trustgraph.NewMemoryGraph(grants) - log.Debugf("Reloaded graph with %d grants expiring at %s", len(grants), expiration) + logrus.Debugf("Reloaded graph with %d grants expiring at %s", len(grants), expiration) if t.autofetch { nextFetch := expiration.Sub(time.Now()) @@ -161,28 +161,28 @@ func (t *TrustStore) fetch() { for bg, ep := range t.baseEndpoints { statement, err := t.fetchBaseGraph(ep) if err != nil { - log.Infof("Trust graph fetch failed: %s", err) + logrus.Infof("Trust graph fetch failed: %s", err) continue } b, err := statement.Bytes() if err != nil { - log.Infof("Bad trust graph statement: %s", err) + logrus.Infof("Bad trust graph statement: %s", err) continue } // TODO check if value differs err = ioutil.WriteFile(path.Join(t.path, bg+".json"), b, 0600) if err != nil { - log.Infof("Error writing trust graph statement: %s", err) + logrus.Infof("Error writing trust graph statement: %s", err) } fetchCount++ } - log.Debugf("Fetched %d base graphs at %s", fetchCount, time.Now()) + logrus.Debugf("Fetched %d base graphs at %s", fetchCount, time.Now()) if fetchCount > 0 { go func() { err := t.reload() if err != nil { - log.Infof("Reload of trust graph failed: %s", err) + logrus.Infof("Reload of trust graph failed: %s", err) } }() t.fetchTime = defaultFetchtime diff --git a/utils/http.go b/utils/http.go index 24eaea56bc38e6e53c00405a9cee731d3a72387e..01251d9ac13928f8a445512396200844464c15da 100644 --- a/utils/http.go +++ b/utils/http.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) // VersionInfo is used to model entities which has a version. @@ -163,6 +163,6 @@ func (h *HTTPRequestFactory) NewRequest(method, urlStr string, body io.Reader, d return nil, err } } - log.Debugf("%v -- HEADERS: %v", req.URL, req.Header) + logrus.Debugf("%v -- HEADERS: %v", req.URL, req.Header) return req, err } diff --git a/utils/utils.go b/utils/utils.go index 4a765eb09c6e72a6bd995a32270aac6a2fd546b1..d0e76bf237aee296b736a18623c04e64ca55f6de 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -18,7 +18,7 @@ import ( "strings" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/fileutils" @@ -157,7 +157,7 @@ func DockerInitPath(localCopy string) string { func GetTotalUsedFds() int { if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil { - log.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err) + logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err) } else { return len(fds) } diff --git a/volumes/repository.go b/volumes/repository.go index ee555e40134518729d334f415a1afabf043b2d65..08c58498182956de1df17a4bb1d7f7e8a6bee1f0 100644 --- a/volumes/repository.go +++ b/volumes/repository.go @@ -7,7 +7,7 @@ import ( "path/filepath" "sync" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/stringid" ) @@ -95,16 +95,16 @@ func (r *Repository) restore() error { } if err := vol.FromDisk(); err != nil { if !os.IsNotExist(err) { - log.Debugf("Error restoring volume: %v", err) + logrus.Debugf("Error restoring volume: %v", err) continue } if err := vol.initialize(); err != nil { - log.Debugf("%s", err) + logrus.Debugf("%s", err) continue } } if err := r.add(vol); err != nil { - log.Debugf("Error restoring volume: %v", err) + logrus.Debugf("Error restoring volume: %v", err) } } return nil