From 7c62cee51edc91634046b4faa6c6f1841cd53ec1 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Fri, 24 Oct 2014 10:12:35 -0700 Subject: [PATCH] Use logrus everywhere for logging Fixed #8761 Signed-off-by: Alexandr Morozov --- api/client/commands.go | 2 +- api/client/hijack.go | 2 +- api/client/utils.go | 2 +- api/common.go | 2 +- api/server/server.go | 2 +- builder/dispatchers.go | 2 +- builder/evaluator.go | 2 +- builder/internals.go | 2 +- daemon/attach.go | 2 +- daemon/container.go | 2 +- daemon/daemon.go | 7 +-- daemon/daemon_aufs.go | 2 +- daemon/delete.go | 2 +- daemon/exec.go | 2 +- daemon/execdriver/lxc/driver.go | 2 +- daemon/graphdriver/aufs/aufs.go | 2 +- daemon/graphdriver/aufs/mount.go | 2 +- .../graphdriver/devmapper/attach_loopback.go | 2 +- daemon/graphdriver/devmapper/deviceset.go | 2 +- daemon/graphdriver/devmapper/devmapper.go | 2 +- daemon/graphdriver/devmapper/driver.go | 2 +- daemon/graphdriver/fsdiff.go | 2 +- daemon/info.go | 2 +- daemon/logs.go | 2 +- daemon/monitor.go | 2 +- daemon/networkdriver/bridge/driver.go | 2 +- daemon/networkdriver/portmapper/mapper.go | 2 +- daemon/volumes.go | 2 +- docker/daemon.go | 2 +- docker/docker.go | 3 ++ docker/log.go | 16 +++++++ graph/export.go | 2 +- graph/graph.go | 2 +- graph/load.go | 2 +- graph/pull.go | 2 +- graph/push.go | 2 +- graph/service.go | 2 +- image/image.go | 2 +- integration/commands_test.go | 2 +- integration/runtime_test.go | 2 +- integration/utils_test.go | 43 ++++++++++--------- pkg/archive/archive.go | 2 +- pkg/archive/changes.go | 2 +- pkg/broadcastwriter/broadcastwriter.go | 2 +- pkg/fileutils/fileutils.go | 2 +- pkg/httputils/resumablerequestreader.go | 2 +- pkg/iptables/iptables.go | 2 +- pkg/log/log.go | 9 ++++ pkg/signal/trap.go | 2 +- pkg/stdcopy/stdcopy.go | 2 +- pkg/tarsum/tarsum.go | 2 +- registry/endpoint.go | 2 +- registry/registry_mock_test.go | 2 +- registry/session.go | 2 +- registry/session_v2.go | 2 +- runconfig/merge.go | 2 +- trust/service.go | 2 +- trust/trusts.go | 2 +- utils/http.go | 2 +- utils/utils.go | 2 +- volumes/repository.go | 2 +- 61 files changed, 111 insertions(+), 79 deletions(-) create mode 100644 docker/log.go diff --git a/api/client/commands.go b/api/client/commands.go index f4ced5ecff..cccdfec851 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -22,6 +22,7 @@ import ( "text/template" "time" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/dockerversion" "github.com/docker/docker/engine" @@ -29,7 +30,6 @@ import ( "github.com/docker/docker/nat" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers/filters" diff --git a/api/client/hijack.go b/api/client/hijack.go index 00170a4a37..adc012bace 100644 --- a/api/client/hijack.go +++ b/api/client/hijack.go @@ -11,9 +11,9 @@ import ( "runtime" "strings" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/dockerversion" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/term" diff --git a/api/client/utils.go b/api/client/utils.go index 11e39729af..b3cd30975b 100644 --- a/api/client/utils.go +++ b/api/client/utils.go @@ -16,10 +16,10 @@ import ( "strings" "syscall" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/dockerversion" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/term" "github.com/docker/docker/registry" diff --git a/api/common.go b/api/common.go index 7470df6ccd..b151552412 100644 --- a/api/common.go +++ b/api/common.go @@ -5,8 +5,8 @@ import ( "mime" "strings" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/version" ) diff --git a/api/server/server.go b/api/server/server.go index ffad992caf..d77a6c22a2 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -23,10 +23,10 @@ import ( "github.com/docker/libcontainer/user" "github.com/gorilla/mux" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/listenbuffer" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/systemd" diff --git a/builder/dispatchers.go b/builder/dispatchers.go index 0c2a580872..fcbbbbdc2d 100644 --- a/builder/dispatchers.go +++ b/builder/dispatchers.go @@ -14,8 +14,8 @@ import ( "regexp" "strings" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/nat" - "github.com/docker/docker/pkg/log" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/runconfig" ) diff --git a/builder/evaluator.go b/builder/evaluator.go index 4122616350..d84bd852f9 100644 --- a/builder/evaluator.go +++ b/builder/evaluator.go @@ -27,10 +27,10 @@ import ( "path" "strings" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/builder/parser" "github.com/docker/docker/daemon" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/registry" "github.com/docker/docker/runconfig" diff --git a/builder/internals.go b/builder/internals.go index 20f3380fb8..d8093507d3 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -18,11 +18,11 @@ import ( "syscall" "time" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/builder/parser" "github.com/docker/docker/daemon" imagepkg "github.com/docker/docker/image" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/system" diff --git a/daemon/attach.go b/daemon/attach.go index e115dac2e0..de583846ee 100644 --- a/daemon/attach.go +++ b/daemon/attach.go @@ -9,7 +9,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/jsonlog" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/utils" ) diff --git a/daemon/container.go b/daemon/container.go index 67bc6942fb..1a0d943d3f 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -25,7 +25,7 @@ import ( "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/networkfs/etchosts" "github.com/docker/docker/pkg/networkfs/resolvconf" "github.com/docker/docker/pkg/promise" diff --git a/daemon/daemon.go b/daemon/daemon.go index caf0c8745f..658d578e4e 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -14,6 +14,7 @@ import ( "github.com/docker/libcontainer/label" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/execdriver/execdrivers" "github.com/docker/docker/daemon/execdriver/lxc" @@ -29,7 +30,6 @@ import ( "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/graphdb" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/log" "github.com/docker/docker/pkg/namesgenerator" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers/kernel" @@ -304,7 +304,7 @@ func (daemon *Daemon) restore() error { ) if !debug { - log.Infof("Loading containers: ") + log.Infof("Loading containers: start.") } dir, err := ioutil.ReadDir(daemon.repository) if err != nil { @@ -392,7 +392,8 @@ func (daemon *Daemon) restore() error { } if !debug { - log.Infof(": done.") + fmt.Println() + log.Infof("Loading containers: done.") } return nil diff --git a/daemon/daemon_aufs.go b/daemon/daemon_aufs.go index a370a4ce3c..6b84d40727 100644 --- a/daemon/daemon_aufs.go +++ b/daemon/daemon_aufs.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/aufs" "github.com/docker/docker/graph" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) // Given the graphdriver ad, if it is aufs, then migrate it. diff --git a/daemon/delete.go b/daemon/delete.go index 77be926c1c..b382f6d843 100644 --- a/daemon/delete.go +++ b/daemon/delete.go @@ -6,7 +6,7 @@ import ( "path" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) func (daemon *Daemon) ContainerRm(job *engine.Job) engine.Status { diff --git a/daemon/exec.go b/daemon/exec.go index a6113b0fca..473a6a0d15 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -14,7 +14,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/pkg/broadcastwriter" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" diff --git a/daemon/execdriver/lxc/driver.go b/daemon/execdriver/lxc/driver.go index 0809b05c1e..ca8573c30f 100644 --- a/daemon/execdriver/lxc/driver.go +++ b/daemon/execdriver/lxc/driver.go @@ -18,7 +18,7 @@ import ( "github.com/kr/pty" "github.com/docker/docker/daemon/execdriver" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/term" "github.com/docker/docker/utils" "github.com/docker/libcontainer/cgroups" diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 8e3ae0b181..a60b8c7f30 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -32,7 +32,7 @@ import ( "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" mountpk "github.com/docker/docker/pkg/mount" "github.com/docker/docker/utils" "github.com/docker/libcontainer/label" diff --git a/daemon/graphdriver/aufs/mount.go b/daemon/graphdriver/aufs/mount.go index fa74e05b07..bb935f6919 100644 --- a/daemon/graphdriver/aufs/mount.go +++ b/daemon/graphdriver/aufs/mount.go @@ -4,7 +4,7 @@ import ( "os/exec" "syscall" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) func Unmount(target string) error { diff --git a/daemon/graphdriver/devmapper/attach_loopback.go b/daemon/graphdriver/devmapper/attach_loopback.go index 9cfa18a4d3..dce5b23ee8 100644 --- a/daemon/graphdriver/devmapper/attach_loopback.go +++ b/daemon/graphdriver/devmapper/attach_loopback.go @@ -7,7 +7,7 @@ import ( "os" "syscall" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) func stringToLoopName(src string) [LoNameSize]uint8 { diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go index b3b5c84399..6c16a2798f 100644 --- a/daemon/graphdriver/devmapper/deviceset.go +++ b/daemon/graphdriver/devmapper/deviceset.go @@ -19,7 +19,7 @@ import ( "time" "github.com/docker/docker/daemon/graphdriver" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/units" "github.com/docker/libcontainer/label" diff --git a/daemon/graphdriver/devmapper/devmapper.go b/daemon/graphdriver/devmapper/devmapper.go index 42cba76230..cd281f0bb3 100644 --- a/daemon/graphdriver/devmapper/devmapper.go +++ b/daemon/graphdriver/devmapper/devmapper.go @@ -9,7 +9,7 @@ import ( "runtime" "syscall" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) type DevmapperLogger interface { diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go index 8f9de85d4e..8c5b148fab 100644 --- a/daemon/graphdriver/devmapper/driver.go +++ b/daemon/graphdriver/devmapper/driver.go @@ -9,7 +9,7 @@ import ( "path" "github.com/docker/docker/daemon/graphdriver" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/units" ) diff --git a/daemon/graphdriver/fsdiff.go b/daemon/graphdriver/fsdiff.go index 5e9d32c1c8..fcfa908853 100644 --- a/daemon/graphdriver/fsdiff.go +++ b/daemon/graphdriver/fsdiff.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/utils" ) diff --git a/daemon/info.go b/daemon/info.go index 3d3c9ba6ca..1bf1b2176b 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/dockerversion" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/parsers/operatingsystem" "github.com/docker/docker/registry" diff --git a/daemon/logs.go b/daemon/logs.go index b4df401efd..31d6fd5223 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -10,7 +10,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/pkg/jsonlog" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/tailfile" "github.com/docker/docker/pkg/timeutils" ) diff --git a/daemon/monitor.go b/daemon/monitor.go index b5dd741012..c0943465e1 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -7,7 +7,7 @@ import ( "time" "github.com/docker/docker/daemon/execdriver" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/runconfig" ) diff --git a/daemon/networkdriver/bridge/driver.go b/daemon/networkdriver/bridge/driver.go index 44d864e709..08b955d03b 100644 --- a/daemon/networkdriver/bridge/driver.go +++ b/daemon/networkdriver/bridge/driver.go @@ -14,7 +14,7 @@ import ( "github.com/docker/docker/daemon/networkdriver/portmapper" "github.com/docker/docker/engine" "github.com/docker/docker/pkg/iptables" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/networkfs/resolvconf" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/libcontainer/netlink" diff --git a/daemon/networkdriver/portmapper/mapper.go b/daemon/networkdriver/portmapper/mapper.go index 24ca0d892f..b7bc90244f 100644 --- a/daemon/networkdriver/portmapper/mapper.go +++ b/daemon/networkdriver/portmapper/mapper.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/daemon/networkdriver/portallocator" "github.com/docker/docker/pkg/iptables" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) type mapping struct { diff --git a/daemon/volumes.go b/daemon/volumes.go index d4ded29161..84de15a609 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -12,7 +12,7 @@ import ( "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/volumes" ) diff --git a/docker/daemon.go b/docker/daemon.go index 2f65878472..dd0baa5fa4 100644 --- a/docker/daemon.go +++ b/docker/daemon.go @@ -3,6 +3,7 @@ package main import ( + log "github.com/Sirupsen/logrus" "github.com/docker/docker/builder" "github.com/docker/docker/builtins" "github.com/docker/docker/daemon" @@ -10,7 +11,6 @@ import ( _ "github.com/docker/docker/daemon/execdriver/native" "github.com/docker/docker/dockerversion" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/signal" ) diff --git a/docker/docker.go b/docker/docker.go index de13c7829c..6d0979723a 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -28,6 +28,7 @@ func main() { if reexec.Init() { return } + flag.Parse() // FIXME: validate daemon flags here @@ -39,6 +40,8 @@ func main() { os.Setenv("DEBUG", "1") } + initLogging(*flDebug) + if len(flHosts) == 0 { defaultHost := os.Getenv("DOCKER_HOST") if defaultHost == "" || *flDaemon { diff --git a/docker/log.go b/docker/log.go new file mode 100644 index 0000000000..a245aed1fb --- /dev/null +++ b/docker/log.go @@ -0,0 +1,16 @@ +package main + +import ( + "os" + + log "github.com/Sirupsen/logrus" +) + +func initLogging(debug bool) { + log.SetOutput(os.Stderr) + if debug { + log.SetLevel(log.DebugLevel) + } else { + log.SetLevel(log.InfoLevel) + } +} diff --git a/graph/export.go b/graph/export.go index 86dc5a342a..591dcff67a 100644 --- a/graph/export.go +++ b/graph/export.go @@ -9,7 +9,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/parsers" ) diff --git a/graph/graph.go b/graph/graph.go index d5d4fcdab1..07fdd5b48d 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -16,7 +16,7 @@ import ( "github.com/docker/docker/dockerversion" "github.com/docker/docker/image" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/truncindex" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" diff --git a/graph/load.go b/graph/load.go index 753f31d2c9..112e7668ed 100644 --- a/graph/load.go +++ b/graph/load.go @@ -10,7 +10,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/image" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) // Loads a set of images into the repository. This is the complementary of ImageExport. diff --git a/graph/pull.go b/graph/pull.go index 5d7e84ed72..c858d9b498 100644 --- a/graph/pull.go +++ b/graph/pull.go @@ -14,7 +14,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/image" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/registry" "github.com/docker/docker/utils" "github.com/docker/libtrust" diff --git a/graph/push.go b/graph/push.go index 3511245b30..0a291d580f 100644 --- a/graph/push.go +++ b/graph/push.go @@ -9,7 +9,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/registry" "github.com/docker/docker/utils" ) diff --git a/graph/service.go b/graph/service.go index 1be986f8d5..3ed7184687 100644 --- a/graph/service.go +++ b/graph/service.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/image" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) func (s *TagStore) Install(eng *engine.Engine) error { diff --git a/image/image.go b/image/image.go index fabd897d29..ccd77b5067 100644 --- a/image/image.go +++ b/image/image.go @@ -10,7 +10,7 @@ import ( "time" "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" ) diff --git a/integration/commands_test.go b/integration/commands_test.go index 532e6f79fa..446fba3f92 100644 --- a/integration/commands_test.go +++ b/integration/commands_test.go @@ -11,7 +11,7 @@ import ( "github.com/docker/docker/api/client" "github.com/docker/docker/daemon" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/term" "github.com/docker/docker/utils" "github.com/docker/libtrust" diff --git a/integration/runtime_test.go b/integration/runtime_test.go index b17d132f8a..00daf2c5c0 100644 --- a/integration/runtime_test.go +++ b/integration/runtime_test.go @@ -21,7 +21,7 @@ import ( "github.com/docker/docker/image" "github.com/docker/docker/nat" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/reexec" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" diff --git a/integration/utils_test.go b/integration/utils_test.go index e1abfa72fc..1d6e3ec609 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -18,20 +18,23 @@ import ( "github.com/docker/docker/builtins" "github.com/docker/docker/daemon" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" ) +type Fataler interface { + Fatal(...interface{}) +} + // This file contains utility functions for docker's unit test suite. // It has to be named XXX_test.go, apparently, in other to access private functions // from other XXX_test.go functions. // Create a temporary daemon suitable for unit testing. // Call t.Fatal() at the first error. -func mkDaemon(f log.Fataler) *daemon.Daemon { +func mkDaemon(f Fataler) *daemon.Daemon { eng := newTestEngine(f, false, "") return mkDaemonFromEngine(eng, f) // FIXME: @@ -40,7 +43,7 @@ func mkDaemon(f log.Fataler) *daemon.Daemon { // [...] } -func createNamedTestContainer(eng *engine.Engine, config *runconfig.Config, f log.Fataler, name string) (shortId string) { +func createNamedTestContainer(eng *engine.Engine, config *runconfig.Config, f Fataler, name string) (shortId string) { job := eng.Job("create", name) if err := job.ImportEnv(config); err != nil { f.Fatal(err) @@ -53,23 +56,23 @@ func createNamedTestContainer(eng *engine.Engine, config *runconfig.Config, f lo return engine.Tail(outputBuffer, 1) } -func createTestContainer(eng *engine.Engine, config *runconfig.Config, f log.Fataler) (shortId string) { +func createTestContainer(eng *engine.Engine, config *runconfig.Config, f Fataler) (shortId string) { return createNamedTestContainer(eng, config, f, "") } -func startContainer(eng *engine.Engine, id string, t log.Fataler) { +func startContainer(eng *engine.Engine, id string, t Fataler) { job := eng.Job("start", id) if err := job.Run(); err != nil { t.Fatal(err) } } -func containerRun(eng *engine.Engine, id string, t log.Fataler) { +func containerRun(eng *engine.Engine, id string, t Fataler) { startContainer(eng, id, t) containerWait(eng, id, t) } -func containerFileExists(eng *engine.Engine, id, dir string, t log.Fataler) bool { +func containerFileExists(eng *engine.Engine, id, dir string, t Fataler) bool { c := getContainer(eng, id, t) if err := c.Mount(); err != nil { t.Fatal(err) @@ -84,7 +87,7 @@ func containerFileExists(eng *engine.Engine, id, dir string, t log.Fataler) bool return true } -func containerAttach(eng *engine.Engine, id string, t log.Fataler) (io.WriteCloser, io.ReadCloser) { +func containerAttach(eng *engine.Engine, id string, t Fataler) (io.WriteCloser, io.ReadCloser) { c := getContainer(eng, id, t) i, err := c.StdinPipe() if err != nil { @@ -97,31 +100,31 @@ func containerAttach(eng *engine.Engine, id string, t log.Fataler) (io.WriteClos return i, o } -func containerWait(eng *engine.Engine, id string, t log.Fataler) int { +func containerWait(eng *engine.Engine, id string, t Fataler) int { ex, _ := getContainer(eng, id, t).WaitStop(-1 * time.Second) return ex } -func containerWaitTimeout(eng *engine.Engine, id string, t log.Fataler) error { +func containerWaitTimeout(eng *engine.Engine, id string, t Fataler) error { _, err := getContainer(eng, id, t).WaitStop(500 * time.Millisecond) return err } -func containerKill(eng *engine.Engine, id string, t log.Fataler) { +func containerKill(eng *engine.Engine, id string, t Fataler) { if err := eng.Job("kill", id).Run(); err != nil { t.Fatal(err) } } -func containerRunning(eng *engine.Engine, id string, t log.Fataler) bool { +func containerRunning(eng *engine.Engine, id string, t Fataler) bool { return getContainer(eng, id, t).IsRunning() } -func containerAssertExists(eng *engine.Engine, id string, t log.Fataler) { +func containerAssertExists(eng *engine.Engine, id string, t Fataler) { getContainer(eng, id, t) } -func containerAssertNotExists(eng *engine.Engine, id string, t log.Fataler) { +func containerAssertNotExists(eng *engine.Engine, id string, t Fataler) { daemon := mkDaemonFromEngine(eng, t) if c := daemon.Get(id); c != nil { t.Fatal(fmt.Errorf("Container %s should not exist", id)) @@ -130,7 +133,7 @@ func containerAssertNotExists(eng *engine.Engine, id string, t log.Fataler) { // assertHttpNotError expect the given response to not have an error. // Otherwise the it causes the test to fail. -func assertHttpNotError(r *httptest.ResponseRecorder, t log.Fataler) { +func assertHttpNotError(r *httptest.ResponseRecorder, t Fataler) { // Non-error http status are [200, 400) if r.Code < http.StatusOK || r.Code >= http.StatusBadRequest { t.Fatal(fmt.Errorf("Unexpected http error: %v", r.Code)) @@ -139,14 +142,14 @@ func assertHttpNotError(r *httptest.ResponseRecorder, t log.Fataler) { // assertHttpError expect the given response to have an error. // Otherwise the it causes the test to fail. -func assertHttpError(r *httptest.ResponseRecorder, t log.Fataler) { +func assertHttpError(r *httptest.ResponseRecorder, t Fataler) { // Non-error http status are [200, 400) if !(r.Code < http.StatusOK || r.Code >= http.StatusBadRequest) { t.Fatal(fmt.Errorf("Unexpected http success code: %v", r.Code)) } } -func getContainer(eng *engine.Engine, id string, t log.Fataler) *daemon.Container { +func getContainer(eng *engine.Engine, id string, t Fataler) *daemon.Container { daemon := mkDaemonFromEngine(eng, t) c := daemon.Get(id) if c == nil { @@ -155,7 +158,7 @@ func getContainer(eng *engine.Engine, id string, t log.Fataler) *daemon.Containe return c } -func mkDaemonFromEngine(eng *engine.Engine, t log.Fataler) *daemon.Daemon { +func mkDaemonFromEngine(eng *engine.Engine, t Fataler) *daemon.Daemon { iDaemon := eng.Hack_GetGlobalVar("httpapi.daemon") if iDaemon == nil { panic("Legacy daemon field not set in engine") @@ -167,7 +170,7 @@ func mkDaemonFromEngine(eng *engine.Engine, t log.Fataler) *daemon.Daemon { return daemon } -func newTestEngine(t log.Fataler, autorestart bool, root string) *engine.Engine { +func newTestEngine(t Fataler, autorestart bool, root string) *engine.Engine { if root == "" { if dir, err := newTestDirectory(unitTestStoreBase); err != nil { t.Fatal(err) @@ -200,7 +203,7 @@ func newTestEngine(t log.Fataler, autorestart bool, root string) *engine.Engine return eng } -func NewTestEngine(t log.Fataler) *engine.Engine { +func NewTestEngine(t Fataler) *engine.Engine { return newTestEngine(t, false, "") } diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index 98149160b3..e4db63ab65 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -19,7 +19,7 @@ import ( "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" "github.com/docker/docker/pkg/fileutils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/system" diff --git a/pkg/archive/changes.go b/pkg/archive/changes.go index 5fbdcc90af..557b5db583 100644 --- a/pkg/archive/changes.go +++ b/pkg/archive/changes.go @@ -12,7 +12,7 @@ import ( "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/system" ) diff --git a/pkg/broadcastwriter/broadcastwriter.go b/pkg/broadcastwriter/broadcastwriter.go index 1898302e79..a9ae1047dc 100644 --- a/pkg/broadcastwriter/broadcastwriter.go +++ b/pkg/broadcastwriter/broadcastwriter.go @@ -7,7 +7,7 @@ import ( "time" "github.com/docker/docker/pkg/jsonlog" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) // BroadcastWriter accumulate multiple io.WriteCloser by stream. diff --git a/pkg/fileutils/fileutils.go b/pkg/fileutils/fileutils.go index acc27f55b5..4e4a91b91a 100644 --- a/pkg/fileutils/fileutils.go +++ b/pkg/fileutils/fileutils.go @@ -1,7 +1,7 @@ package fileutils import ( - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "path/filepath" ) diff --git a/pkg/httputils/resumablerequestreader.go b/pkg/httputils/resumablerequestreader.go index 3cd1f49179..10edd43a98 100644 --- a/pkg/httputils/resumablerequestreader.go +++ b/pkg/httputils/resumablerequestreader.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) type resumableRequestReader struct { diff --git a/pkg/iptables/iptables.go b/pkg/iptables/iptables.go index b8d9e56705..53e6e1430c 100644 --- a/pkg/iptables/iptables.go +++ b/pkg/iptables/iptables.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) type Action string diff --git a/pkg/log/log.go b/pkg/log/log.go index b06d958cb1..d636f763ef 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -8,9 +8,18 @@ import ( "strings" "time" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/timeutils" ) +func init() { + log.SetOutput(os.Stderr) + log.SetLevel(log.InfoLevel) + if os.Getenv("DEBUG") != "" { + log.SetLevel(log.DebugLevel) + } +} + type priority int const ( diff --git a/pkg/signal/trap.go b/pkg/signal/trap.go index 42ddb4d277..9be82671a1 100644 --- a/pkg/signal/trap.go +++ b/pkg/signal/trap.go @@ -6,7 +6,7 @@ import ( "sync/atomic" "syscall" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) // Trap sets up a simplified signal "trap", appropriate for common diff --git a/pkg/stdcopy/stdcopy.go b/pkg/stdcopy/stdcopy.go index 79e15bc852..a61779ce53 100644 --- a/pkg/stdcopy/stdcopy.go +++ b/pkg/stdcopy/stdcopy.go @@ -5,7 +5,7 @@ import ( "errors" "io" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) const ( diff --git a/pkg/tarsum/tarsum.go b/pkg/tarsum/tarsum.go index 6581f3f234..88d603c45b 100644 --- a/pkg/tarsum/tarsum.go +++ b/pkg/tarsum/tarsum.go @@ -13,7 +13,7 @@ import ( "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) const ( diff --git a/registry/endpoint.go b/registry/endpoint.go index 58311d32d1..05b5c08be1 100644 --- a/registry/endpoint.go +++ b/registry/endpoint.go @@ -9,7 +9,7 @@ import ( "net/url" "strings" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) // scans string for api version in the URL path. returns the trimmed hostname, if version found, string and API version. diff --git a/registry/registry_mock_test.go b/registry/registry_mock_test.go index 967d8b2615..02884c6224 100644 --- a/registry/registry_mock_test.go +++ b/registry/registry_mock_test.go @@ -15,7 +15,7 @@ import ( "github.com/gorilla/mux" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) var ( diff --git a/registry/session.go b/registry/session.go index ff0be343d5..de97db3aea 100644 --- a/registry/session.go +++ b/registry/session.go @@ -18,7 +18,7 @@ import ( "time" "github.com/docker/docker/pkg/httputils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/utils" ) diff --git a/registry/session_v2.go b/registry/session_v2.go index c0bc19b337..20e9e2ee9c 100644 --- a/registry/session_v2.go +++ b/registry/session_v2.go @@ -8,7 +8,7 @@ import ( "net/url" "strconv" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/utils" "github.com/gorilla/mux" ) diff --git a/runconfig/merge.go b/runconfig/merge.go index 0c60d1df0b..f084d70dd8 100644 --- a/runconfig/merge.go +++ b/runconfig/merge.go @@ -4,7 +4,7 @@ import ( "strings" "github.com/docker/docker/nat" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) func Merge(userConf, imageConf *Config) error { diff --git a/trust/service.go b/trust/service.go index c056ac7191..592515db18 100644 --- a/trust/service.go +++ b/trust/service.go @@ -5,7 +5,7 @@ import ( "time" "github.com/docker/docker/engine" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/libtrust" ) diff --git a/trust/trusts.go b/trust/trusts.go index a3c0f5f548..33354bd3ce 100644 --- a/trust/trusts.go +++ b/trust/trusts.go @@ -12,7 +12,7 @@ import ( "sync" "time" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/libtrust/trustgraph" ) diff --git a/utils/http.go b/utils/http.go index c877eefdd2..bcf1865e2e 100644 --- a/utils/http.go +++ b/utils/http.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) // VersionInfo is used to model entities which has a version. diff --git a/utils/utils.go b/utils/utils.go index 792b80bd51..b495f442a1 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -23,7 +23,7 @@ import ( "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" ) type KeyValuePair struct { diff --git a/volumes/repository.go b/volumes/repository.go index 2383f34a93..eddb295150 100644 --- a/volumes/repository.go +++ b/volumes/repository.go @@ -8,7 +8,7 @@ import ( "sync" "github.com/docker/docker/daemon/graphdriver" - "github.com/docker/docker/pkg/log" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/utils" )