From 4e48c52f5debe378194a878085acb48da9e8c3ed Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 31 Jul 2017 13:51:17 -0700 Subject: [PATCH] vndr: Update logrus package to v1.0.0 Signed-off-by: Mrunal Patel --- cmd/crio/daemon_linux.go | 2 +- cmd/crio/main.go | 2 +- cmd/crioctl/main.go | 2 +- cmd/kpod/history.go | 2 +- cmd/kpod/main.go | 2 +- cmd/kpod/pull.go | 2 +- cmd/kpod/save.go | 2 +- libkpod/container_server.go | 2 +- libkpod/image/copy_ref.go | 2 +- libkpod/sandbox/sandbox.go | 2 +- oci/oci.go | 2 +- pkg/ocicni/ocicni.go | 2 +- pkg/storage/runtime.go | 2 +- server/container_attach.go | 2 +- server/container_create.go | 2 +- server/container_exec.go | 2 +- server/container_execsync.go | 2 +- server/container_list.go | 2 +- server/container_portforward.go | 2 +- server/container_remove.go | 2 +- server/container_start.go | 2 +- server/container_status.go | 2 +- server/container_stop.go | 2 +- server/image_list.go | 2 +- server/image_pull.go | 2 +- server/image_remove.go | 2 +- server/image_status.go | 2 +- server/sandbox_list.go | 2 +- server/sandbox_remove.go | 2 +- server/sandbox_run.go | 2 +- server/sandbox_status.go | 2 +- server/sandbox_stop.go | 2 +- server/server.go | 2 +- test/bin2img/bin2img.go | 2 +- test/copyimg/copyimg.go | 2 +- vendor.conf | 2 +- .../Sirupsen/logrus/terminal_windows.go | 33 -------- .../{Sirupsen => sirupsen}/logrus/LICENSE | 0 .../{Sirupsen => sirupsen}/logrus/README.md | 75 +++++++++++------ .../{Sirupsen => sirupsen}/logrus/alt_exit.go | 2 +- .../{Sirupsen => sirupsen}/logrus/doc.go | 4 +- .../{Sirupsen => sirupsen}/logrus/entry.go | 36 ++++---- .../{Sirupsen => sirupsen}/logrus/exported.go | 4 +- .../logrus/formatter.go | 0 .../{Sirupsen => sirupsen}/logrus/hooks.go | 0 .../logrus/json_formatter.go | 4 +- .../{Sirupsen => sirupsen}/logrus/logger.go | 51 +++++++----- .../{Sirupsen => sirupsen}/logrus/logrus.go | 2 +- .../logrus/terminal_appengine.go | 0 .../logrus/terminal_bsd.go | 0 .../logrus/terminal_linux.go | 0 .../logrus/terminal_notwindows.go | 0 .../logrus/terminal_solaris.go | 0 .../sirupsen/logrus/terminal_windows.go | 82 +++++++++++++++++++ .../logrus/text_formatter.go | 0 .../{Sirupsen => sirupsen}/logrus/writer.go | 0 56 files changed, 224 insertions(+), 141 deletions(-) delete mode 100644 vendor/github.com/Sirupsen/logrus/terminal_windows.go rename vendor/github.com/{Sirupsen => sirupsen}/logrus/LICENSE (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/README.md (86%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/alt_exit.go (96%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/doc.go (83%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/entry.go (89%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/exported.go (99%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/formatter.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/json_formatter.go (94%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/logger.go (88%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/logrus.go (99%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_appengine.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_bsd.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_linux.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_notwindows.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_solaris.go (100%) create mode 100644 vendor/github.com/sirupsen/logrus/terminal_windows.go rename vendor/github.com/{Sirupsen => sirupsen}/logrus/text_formatter.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/writer.go (100%) diff --git a/cmd/crio/daemon_linux.go b/cmd/crio/daemon_linux.go index 94ecb61f..d88fe328 100644 --- a/cmd/crio/daemon_linux.go +++ b/cmd/crio/daemon_linux.go @@ -3,7 +3,7 @@ package main import ( - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" systemdDaemon "github.com/coreos/go-systemd/daemon" ) diff --git a/cmd/crio/main.go b/cmd/crio/main.go index 98c7a8e8..74f7d5ed 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -10,7 +10,7 @@ import ( "sort" "strings" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage/pkg/reexec" "github.com/kubernetes-incubator/cri-o/libkpod" "github.com/kubernetes-incubator/cri-o/server" diff --git a/cmd/crioctl/main.go b/cmd/crioctl/main.go index e8d30bc7..f444ce66 100644 --- a/cmd/crioctl/main.go +++ b/cmd/crioctl/main.go @@ -7,7 +7,7 @@ import ( "os" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/urfave/cli" "google.golang.org/grpc" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/cmd/kpod/history.go b/cmd/kpod/history.go index a737c342..1c8df788 100644 --- a/cmd/kpod/history.go +++ b/cmd/kpod/history.go @@ -11,7 +11,7 @@ import ( "strconv" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" is "github.com/containers/image/storage" "github.com/containers/storage" units "github.com/docker/go-units" diff --git a/cmd/kpod/main.go b/cmd/kpod/main.go index 5741d684..ba7d79cb 100644 --- a/cmd/kpod/main.go +++ b/cmd/kpod/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage/pkg/reexec" "github.com/urfave/cli" ) diff --git a/cmd/kpod/pull.go b/cmd/kpod/pull.go index 1ece94bd..e63f4123 100644 --- a/cmd/kpod/pull.go +++ b/cmd/kpod/pull.go @@ -1,7 +1,7 @@ package main import ( - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/libkpod/common" libkpodimage "github.com/kubernetes-incubator/cri-o/libkpod/image" "github.com/pkg/errors" diff --git a/cmd/kpod/save.go b/cmd/kpod/save.go index ff11d084..7b3ea6fa 100644 --- a/cmd/kpod/save.go +++ b/cmd/kpod/save.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage" libkpodimage "github.com/kubernetes-incubator/cri-o/libkpod/image" "github.com/pkg/errors" diff --git a/libkpod/container_server.go b/libkpod/container_server.go index 0b3e7fca..e716138e 100644 --- a/libkpod/container_server.go +++ b/libkpod/container_server.go @@ -5,7 +5,7 @@ import ( "fmt" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/image/types" cstorage "github.com/containers/storage" "github.com/docker/docker/pkg/ioutils" diff --git a/libkpod/image/copy_ref.go b/libkpod/image/copy_ref.go index d36c44fd..2719dddd 100644 --- a/libkpod/image/copy_ref.go +++ b/libkpod/image/copy_ref.go @@ -9,7 +9,7 @@ import ( "path/filepath" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/image/docker/reference" "github.com/containers/image/image" is "github.com/containers/image/storage" diff --git a/libkpod/sandbox/sandbox.go b/libkpod/sandbox/sandbox.go index e3b94237..10650e9a 100644 --- a/libkpod/sandbox/sandbox.go +++ b/libkpod/sandbox/sandbox.go @@ -8,7 +8,7 @@ import ( "path/filepath" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containernetworking/cni/pkg/ns" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/symlink" diff --git a/oci/oci.go b/oci/oci.go index 75660fdc..d8e61551 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -13,7 +13,7 @@ import ( "syscall" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/utils" rspec "github.com/opencontainers/runtime-spec/specs-go" "golang.org/x/sys/unix" diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index 0a0e1740..542bba09 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -7,7 +7,7 @@ import ( "sort" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containernetworking/cni/libcni" cnitypes "github.com/containernetworking/cni/pkg/types" "github.com/fsnotify/fsnotify" diff --git a/pkg/storage/runtime.go b/pkg/storage/runtime.go index c2e173a5..19085fa3 100644 --- a/pkg/storage/runtime.go +++ b/pkg/storage/runtime.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/image/copy" istorage "github.com/containers/image/storage" "github.com/containers/image/transports/alltransports" diff --git a/server/container_attach.go b/server/container_attach.go index d81e0c32..99c96c56 100644 --- a/server/container_attach.go +++ b/server/container_attach.go @@ -7,7 +7,7 @@ import ( "os" "path/filepath" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "github.com/kubernetes-incubator/cri-o/utils" "golang.org/x/net/context" diff --git a/server/container_create.go b/server/container_create.go index f5029b06..87c9b934 100644 --- a/server/container_create.go +++ b/server/container_create.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/symlink" "github.com/kubernetes-incubator/cri-o/libkpod" diff --git a/server/container_exec.go b/server/container_exec.go index d8f6c343..1cbb4235 100644 --- a/server/container_exec.go +++ b/server/container_exec.go @@ -6,7 +6,7 @@ import ( "os" "os/exec" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/docker/docker/pkg/pools" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" diff --git a/server/container_execsync.go b/server/container_execsync.go index a3055acb..df48f9b0 100644 --- a/server/container_execsync.go +++ b/server/container_execsync.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/server/container_list.go b/server/container_list.go index c400d656..869c0002 100644 --- a/server/container_list.go +++ b/server/container_list.go @@ -1,7 +1,7 @@ package server import ( - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" "k8s.io/apimachinery/pkg/fields" diff --git a/server/container_portforward.go b/server/container_portforward.go index db9c5013..b974e4fd 100644 --- a/server/container_portforward.go +++ b/server/container_portforward.go @@ -7,7 +7,7 @@ import ( "os/exec" "strings" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/docker/docker/pkg/pools" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" diff --git a/server/container_remove.go b/server/container_remove.go index 8e330e60..944fbc2b 100644 --- a/server/container_remove.go +++ b/server/container_remove.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/server/container_start.go b/server/container_start.go index b8c7fdb0..7d9f104c 100644 --- a/server/container_start.go +++ b/server/container_start.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/server/container_status.go b/server/container_status.go index ece493eb..634ca096 100644 --- a/server/container_status.go +++ b/server/container_status.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/docker/distribution/reference" "github.com/kubernetes-incubator/cri-o/oci" rspec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/server/container_stop.go b/server/container_stop.go index ccbde3cc..b0a50f94 100644 --- a/server/container_stop.go +++ b/server/container_stop.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/server/image_list.go b/server/image_list.go index 1cc8cb1b..9de603a8 100644 --- a/server/image_list.go +++ b/server/image_list.go @@ -1,7 +1,7 @@ package server import ( - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" ) diff --git a/server/image_pull.go b/server/image_pull.go index 298b5b24..62143996 100644 --- a/server/image_pull.go +++ b/server/image_pull.go @@ -4,7 +4,7 @@ import ( "encoding/base64" "strings" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/image/copy" "github.com/containers/image/types" "golang.org/x/net/context" diff --git a/server/image_remove.go b/server/image_remove.go index cafb5a73..9c16c403 100644 --- a/server/image_remove.go +++ b/server/image_remove.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" ) diff --git a/server/image_status.go b/server/image_status.go index eb0a1226..4c6c992d 100644 --- a/server/image_status.go +++ b/server/image_status.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/server/sandbox_list.go b/server/sandbox_list.go index faf15a6b..0f7c0476 100644 --- a/server/sandbox_list.go +++ b/server/sandbox_list.go @@ -1,7 +1,7 @@ package server import ( - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/libkpod/sandbox" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" diff --git a/server/sandbox_remove.go b/server/sandbox_remove.go index 676ea1d8..109c5d10 100644 --- a/server/sandbox_remove.go +++ b/server/sandbox_remove.go @@ -3,7 +3,7 @@ package server import ( "fmt" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage" "github.com/kubernetes-incubator/cri-o/libkpod/sandbox" "github.com/kubernetes-incubator/cri-o/oci" diff --git a/server/sandbox_run.go b/server/sandbox_run.go index 9bcd9005..d0157b6b 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage" "github.com/kubernetes-incubator/cri-o/libkpod/sandbox" "github.com/kubernetes-incubator/cri-o/oci" diff --git a/server/sandbox_status.go b/server/sandbox_status.go index 48eb6695..6097c579 100644 --- a/server/sandbox_status.go +++ b/server/sandbox_status.go @@ -1,7 +1,7 @@ package server import ( - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" diff --git a/server/sandbox_stop.go b/server/sandbox_stop.go index 3f21b9e7..a3d293ee 100644 --- a/server/sandbox_stop.go +++ b/server/sandbox_stop.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/storage" "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/symlink" diff --git a/server/server.go b/server/server.go index 477bfdf1..4106c2c4 100644 --- a/server/server.go +++ b/server/server.go @@ -10,7 +10,7 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" cstorage "github.com/containers/storage" "github.com/kubernetes-incubator/cri-o/libkpod" "github.com/kubernetes-incubator/cri-o/libkpod/sandbox" diff --git a/test/bin2img/bin2img.go b/test/bin2img/bin2img.go index ca0e703b..e2e9226b 100644 --- a/test/bin2img/bin2img.go +++ b/test/bin2img/bin2img.go @@ -8,7 +8,7 @@ import ( "os" "runtime" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/image/storage" "github.com/containers/image/types" sstorage "github.com/containers/storage" diff --git a/test/copyimg/copyimg.go b/test/copyimg/copyimg.go index 324477bc..3fc516c3 100644 --- a/test/copyimg/copyimg.go +++ b/test/copyimg/copyimg.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/containers/image/copy" "github.com/containers/image/signature" "github.com/containers/image/storage" diff --git a/vendor.conf b/vendor.conf index fcb1f559..09e8dc1c 100644 --- a/vendor.conf +++ b/vendor.conf @@ -4,7 +4,7 @@ k8s.io/client-go v3.0.0-beta.0 https://github.com/kubernetes/client-go k8s.io/apimachinery release-1.6 https://github.com/kubernetes/apimachinery k8s.io/apiserver release-1.6 https://github.com/kubernetes/apiserver # -github.com/Sirupsen/logrus v0.11.5 +github.com/sirupsen/logrus v1.0.0 github.com/containers/image 106607808da3cff168be56821e994611c919d283 github.com/ostreedev/ostree-go master github.com/containers/storage 5d8c2f87387fa5be9fa526ae39fbd79b8bdf27be diff --git a/vendor/github.com/Sirupsen/logrus/terminal_windows.go b/vendor/github.com/Sirupsen/logrus/terminal_windows.go deleted file mode 100644 index 05d2f91f..00000000 --- a/vendor/github.com/Sirupsen/logrus/terminal_windows.go +++ /dev/null @@ -1,33 +0,0 @@ -// Based on ssh/terminal: -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows,!appengine - -package logrus - -import ( - "io" - "os" - "syscall" - "unsafe" -) - -var kernel32 = syscall.NewLazyDLL("kernel32.dll") - -var ( - procGetConsoleMode = kernel32.NewProc("GetConsoleMode") -) - -// IsTerminal returns true if stderr's file descriptor is a terminal. -func IsTerminal(f io.Writer) bool { - switch v := f.(type) { - case *os.File: - var st uint32 - r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) - return r != 0 && e == 0 - default: - return false - } -} diff --git a/vendor/github.com/Sirupsen/logrus/LICENSE b/vendor/github.com/sirupsen/logrus/LICENSE similarity index 100% rename from vendor/github.com/Sirupsen/logrus/LICENSE rename to vendor/github.com/sirupsen/logrus/LICENSE diff --git a/vendor/github.com/Sirupsen/logrus/README.md b/vendor/github.com/sirupsen/logrus/README.md similarity index 86% rename from vendor/github.com/Sirupsen/logrus/README.md rename to vendor/github.com/sirupsen/logrus/README.md index 640cf61f..cbe8b696 100644 --- a/vendor/github.com/Sirupsen/logrus/README.md +++ b/vendor/github.com/sirupsen/logrus/README.md @@ -1,10 +1,4 @@ -# Logrus :walrus: [![Build Status](https://travis-ci.org/Sirupsen/logrus.svg?branch=master)](https://travis-ci.org/Sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/Sirupsen/logrus?status.svg)](https://godoc.org/github.com/Sirupsen/logrus) - -**Seeing weird case-sensitive problems?** See [this -issue](https://github.com/sirupsen/logrus/issues/451#issuecomment-264332021). -This change has been reverted. I apologize for causing this. I greatly -underestimated the impact this would have. Logrus strives for stability and -backwards compatibility and failed to provide that. +# Logrus :walrus: [![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus) Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not @@ -13,6 +7,17 @@ many large deployments. The core API is unlikely to change much but please version control your Logrus to make sure you aren't fetching latest `master` on every build.** +**Seeing weird case-sensitive problems?** Unfortunately, the author failed to +realize the consequences of renaming to lower-case. Due to the Go package +environment, this caused issues. Regretfully, there's no turning back now. +Everything using `logrus` will need to use the lower-case: +`github.com/sirupsen/logrus`. Any package that isn't, should be changed. + +I am terribly sorry for this inconvenience. Logrus strives hard for backwards +compatibility, and the author failed to realize the cascading consequences of +such a name-change. To fix Glide, see [these +comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437). + Nicely color-coded in development (when a TTY is attached, otherwise just plain text): @@ -52,6 +57,12 @@ time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x20822 exit status 1 ``` +#### Case-sensitivity + +The organization's name was changed to lower-case--and this will not be changed +back. If you are getting import conflicts due to case sensitivity, please use +the lower-case import: `github.com/sirupsen/logrus`. + #### Example The simplest way to use Logrus is simply the package-level exported logger: @@ -60,7 +71,7 @@ The simplest way to use Logrus is simply the package-level exported logger: package main import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) func main() { @@ -71,7 +82,7 @@ func main() { ``` Note that it's completely api-compatible with the stdlib logger, so you can -replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"` +replace your `log` imports everywhere with `log "github.com/sirupsen/logrus"` and you'll now have the flexibility of Logrus. You can customize it all you want: @@ -80,7 +91,7 @@ package main import ( "os" - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) func init() { @@ -130,7 +141,8 @@ application, you can also create an instance of the `logrus` Logger: package main import ( - "github.com/Sirupsen/logrus" + "os" + "github.com/sirupsen/logrus" ) // Create a new instance of the logger. You can have any number of instances. @@ -158,7 +170,7 @@ func main() { #### Fields -Logrus encourages careful, structured logging though logging fields instead of +Logrus encourages careful, structured logging through logging fields instead of long, unparseable error messages. For example, instead of: `log.Fatalf("Failed to send event %s to topic %s with key %d")`, you should log the much more discoverable: @@ -189,7 +201,7 @@ application or parts of one. For example, you may want to always log the every line, you can create a `logrus.Entry` to pass around instead: ```go -requestLogger := log.WithFields(log.Fields{"request_id": request_id, user_ip: user_ip}) +requestLogger := log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip}) requestLogger.Info("something happened on that request") # will log request_id and user_ip requestLogger.Warn("something not great happened") ``` @@ -205,9 +217,9 @@ Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in ```go import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake" - logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" + logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" "log/syslog" ) @@ -235,14 +247,16 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v | [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) | | [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | | [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | +| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) | | [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch| +| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/) | [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | | [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) | | [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | | [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | | [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | | [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | -| [Influxus] (http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB] (http://influxdata.com/) | +| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) | | [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | | [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka | | [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | @@ -267,9 +281,11 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v | [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) | | [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| | [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | +| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. | | [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) | | [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | | [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash | +| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) | #### Level logging @@ -318,7 +334,7 @@ could do: ```go import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) init() { @@ -421,7 +437,7 @@ entries. It should not be a feature of the application-level logger. | Tool | Description | | ---- | ----------- | |[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.| -|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper arround Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) | +|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper around Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) | #### Testing @@ -431,15 +447,24 @@ Logrus has a built in facility for asserting the presence of log messages. This * a test logger (`test.NewNullLogger`) that just records log messages (and does not output any): ```go -logger, hook := NewNullLogger() -logger.Error("Hello error") +import( + "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus/hooks/null" + "github.com/stretchr/testify/assert" + "testing" +) -assert.Equal(1, len(hook.Entries)) -assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level) -assert.Equal("Hello error", hook.LastEntry().Message) +func TestSomething(t*testing.T){ + logger, hook := null.NewNullLogger() + logger.Error("Helloerror") -hook.Reset() -assert.Nil(hook.LastEntry()) + assert.Equal(t, 1, len(hook.Entries)) + assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level) + assert.Equal(t, "Helloerror", hook.LastEntry().Message) + + hook.Reset() + assert.Nil(t, hook.LastEntry()) +} ``` #### Fatal handlers diff --git a/vendor/github.com/Sirupsen/logrus/alt_exit.go b/vendor/github.com/sirupsen/logrus/alt_exit.go similarity index 96% rename from vendor/github.com/Sirupsen/logrus/alt_exit.go rename to vendor/github.com/sirupsen/logrus/alt_exit.go index b4c9e847..8af90637 100644 --- a/vendor/github.com/Sirupsen/logrus/alt_exit.go +++ b/vendor/github.com/sirupsen/logrus/alt_exit.go @@ -1,7 +1,7 @@ package logrus // The following code was sourced and modified from the -// https://bitbucket.org/tebeka/atexit package governed by the following license: +// https://github.com/tebeka/atexit package governed by the following license: // // Copyright (c) 2012 Miki Tebeka . // diff --git a/vendor/github.com/Sirupsen/logrus/doc.go b/vendor/github.com/sirupsen/logrus/doc.go similarity index 83% rename from vendor/github.com/Sirupsen/logrus/doc.go rename to vendor/github.com/sirupsen/logrus/doc.go index dddd5f87..da67aba0 100644 --- a/vendor/github.com/Sirupsen/logrus/doc.go +++ b/vendor/github.com/sirupsen/logrus/doc.go @@ -7,7 +7,7 @@ The simplest way to use Logrus is simply the package-level exported logger: package main import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) func main() { @@ -21,6 +21,6 @@ The simplest way to use Logrus is simply the package-level exported logger: Output: time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 -For a full guide visit https://github.com/Sirupsen/logrus +For a full guide visit https://github.com/sirupsen/logrus */ package logrus diff --git a/vendor/github.com/Sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go similarity index 89% rename from vendor/github.com/Sirupsen/logrus/entry.go rename to vendor/github.com/sirupsen/logrus/entry.go index 4edbe7a2..320e5d5b 100644 --- a/vendor/github.com/Sirupsen/logrus/entry.go +++ b/vendor/github.com/sirupsen/logrus/entry.go @@ -126,7 +126,7 @@ func (entry Entry) log(level Level, msg string) { } func (entry *Entry) Debug(args ...interface{}) { - if entry.Logger.Level >= DebugLevel { + if entry.Logger.level() >= DebugLevel { entry.log(DebugLevel, fmt.Sprint(args...)) } } @@ -136,13 +136,13 @@ func (entry *Entry) Print(args ...interface{}) { } func (entry *Entry) Info(args ...interface{}) { - if entry.Logger.Level >= InfoLevel { + if entry.Logger.level() >= InfoLevel { entry.log(InfoLevel, fmt.Sprint(args...)) } } func (entry *Entry) Warn(args ...interface{}) { - if entry.Logger.Level >= WarnLevel { + if entry.Logger.level() >= WarnLevel { entry.log(WarnLevel, fmt.Sprint(args...)) } } @@ -152,20 +152,20 @@ func (entry *Entry) Warning(args ...interface{}) { } func (entry *Entry) Error(args ...interface{}) { - if entry.Logger.Level >= ErrorLevel { + if entry.Logger.level() >= ErrorLevel { entry.log(ErrorLevel, fmt.Sprint(args...)) } } func (entry *Entry) Fatal(args ...interface{}) { - if entry.Logger.Level >= FatalLevel { + if entry.Logger.level() >= FatalLevel { entry.log(FatalLevel, fmt.Sprint(args...)) } Exit(1) } func (entry *Entry) Panic(args ...interface{}) { - if entry.Logger.Level >= PanicLevel { + if entry.Logger.level() >= PanicLevel { entry.log(PanicLevel, fmt.Sprint(args...)) } panic(fmt.Sprint(args...)) @@ -174,13 +174,13 @@ func (entry *Entry) Panic(args ...interface{}) { // Entry Printf family functions func (entry *Entry) Debugf(format string, args ...interface{}) { - if entry.Logger.Level >= DebugLevel { + if entry.Logger.level() >= DebugLevel { entry.Debug(fmt.Sprintf(format, args...)) } } func (entry *Entry) Infof(format string, args ...interface{}) { - if entry.Logger.Level >= InfoLevel { + if entry.Logger.level() >= InfoLevel { entry.Info(fmt.Sprintf(format, args...)) } } @@ -190,7 +190,7 @@ func (entry *Entry) Printf(format string, args ...interface{}) { } func (entry *Entry) Warnf(format string, args ...interface{}) { - if entry.Logger.Level >= WarnLevel { + if entry.Logger.level() >= WarnLevel { entry.Warn(fmt.Sprintf(format, args...)) } } @@ -200,20 +200,20 @@ func (entry *Entry) Warningf(format string, args ...interface{}) { } func (entry *Entry) Errorf(format string, args ...interface{}) { - if entry.Logger.Level >= ErrorLevel { + if entry.Logger.level() >= ErrorLevel { entry.Error(fmt.Sprintf(format, args...)) } } func (entry *Entry) Fatalf(format string, args ...interface{}) { - if entry.Logger.Level >= FatalLevel { + if entry.Logger.level() >= FatalLevel { entry.Fatal(fmt.Sprintf(format, args...)) } Exit(1) } func (entry *Entry) Panicf(format string, args ...interface{}) { - if entry.Logger.Level >= PanicLevel { + if entry.Logger.level() >= PanicLevel { entry.Panic(fmt.Sprintf(format, args...)) } } @@ -221,13 +221,13 @@ func (entry *Entry) Panicf(format string, args ...interface{}) { // Entry Println family functions func (entry *Entry) Debugln(args ...interface{}) { - if entry.Logger.Level >= DebugLevel { + if entry.Logger.level() >= DebugLevel { entry.Debug(entry.sprintlnn(args...)) } } func (entry *Entry) Infoln(args ...interface{}) { - if entry.Logger.Level >= InfoLevel { + if entry.Logger.level() >= InfoLevel { entry.Info(entry.sprintlnn(args...)) } } @@ -237,7 +237,7 @@ func (entry *Entry) Println(args ...interface{}) { } func (entry *Entry) Warnln(args ...interface{}) { - if entry.Logger.Level >= WarnLevel { + if entry.Logger.level() >= WarnLevel { entry.Warn(entry.sprintlnn(args...)) } } @@ -247,20 +247,20 @@ func (entry *Entry) Warningln(args ...interface{}) { } func (entry *Entry) Errorln(args ...interface{}) { - if entry.Logger.Level >= ErrorLevel { + if entry.Logger.level() >= ErrorLevel { entry.Error(entry.sprintlnn(args...)) } } func (entry *Entry) Fatalln(args ...interface{}) { - if entry.Logger.Level >= FatalLevel { + if entry.Logger.level() >= FatalLevel { entry.Fatal(entry.sprintlnn(args...)) } Exit(1) } func (entry *Entry) Panicln(args ...interface{}) { - if entry.Logger.Level >= PanicLevel { + if entry.Logger.level() >= PanicLevel { entry.Panic(entry.sprintlnn(args...)) } } diff --git a/vendor/github.com/Sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go similarity index 99% rename from vendor/github.com/Sirupsen/logrus/exported.go rename to vendor/github.com/sirupsen/logrus/exported.go index 9a0120ac..1aeaa90b 100644 --- a/vendor/github.com/Sirupsen/logrus/exported.go +++ b/vendor/github.com/sirupsen/logrus/exported.go @@ -31,14 +31,14 @@ func SetFormatter(formatter Formatter) { func SetLevel(level Level) { std.mu.Lock() defer std.mu.Unlock() - std.Level = level + std.setLevel(level) } // GetLevel returns the standard logger level. func GetLevel() Level { std.mu.Lock() defer std.mu.Unlock() - return std.Level + return std.level() } // AddHook adds a hook to the standard logger hooks. diff --git a/vendor/github.com/Sirupsen/logrus/formatter.go b/vendor/github.com/sirupsen/logrus/formatter.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/formatter.go rename to vendor/github.com/sirupsen/logrus/formatter.go diff --git a/vendor/github.com/Sirupsen/logrus/hooks.go b/vendor/github.com/sirupsen/logrus/hooks.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks.go rename to vendor/github.com/sirupsen/logrus/hooks.go diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/sirupsen/logrus/json_formatter.go similarity index 94% rename from vendor/github.com/Sirupsen/logrus/json_formatter.go rename to vendor/github.com/sirupsen/logrus/json_formatter.go index 266554e9..e787ea17 100644 --- a/vendor/github.com/Sirupsen/logrus/json_formatter.go +++ b/vendor/github.com/sirupsen/logrus/json_formatter.go @@ -35,7 +35,7 @@ type JSONFormatter struct { // FieldMap: FieldMap{ // FieldKeyTime: "@timestamp", // FieldKeyLevel: "@level", - // FieldKeyLevel: "@message", + // FieldKeyMsg: "@message", // }, // } FieldMap FieldMap @@ -47,7 +47,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { switch v := v.(type) { case error: // Otherwise errors are ignored by `encoding/json` - // https://github.com/Sirupsen/logrus/issues/137 + // https://github.com/sirupsen/logrus/issues/137 data[k] = v.Error() default: data[k] = v diff --git a/vendor/github.com/Sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go similarity index 88% rename from vendor/github.com/Sirupsen/logrus/logger.go rename to vendor/github.com/sirupsen/logrus/logger.go index b769f3d3..370fff5d 100644 --- a/vendor/github.com/Sirupsen/logrus/logger.go +++ b/vendor/github.com/sirupsen/logrus/logger.go @@ -4,6 +4,7 @@ import ( "io" "os" "sync" + "sync/atomic" ) type Logger struct { @@ -112,7 +113,7 @@ func (logger *Logger) WithError(err error) *Entry { } func (logger *Logger) Debugf(format string, args ...interface{}) { - if logger.Level >= DebugLevel { + if logger.level() >= DebugLevel { entry := logger.newEntry() entry.Debugf(format, args...) logger.releaseEntry(entry) @@ -120,7 +121,7 @@ func (logger *Logger) Debugf(format string, args ...interface{}) { } func (logger *Logger) Infof(format string, args ...interface{}) { - if logger.Level >= InfoLevel { + if logger.level() >= InfoLevel { entry := logger.newEntry() entry.Infof(format, args...) logger.releaseEntry(entry) @@ -134,7 +135,7 @@ func (logger *Logger) Printf(format string, args ...interface{}) { } func (logger *Logger) Warnf(format string, args ...interface{}) { - if logger.Level >= WarnLevel { + if logger.level() >= WarnLevel { entry := logger.newEntry() entry.Warnf(format, args...) logger.releaseEntry(entry) @@ -142,7 +143,7 @@ func (logger *Logger) Warnf(format string, args ...interface{}) { } func (logger *Logger) Warningf(format string, args ...interface{}) { - if logger.Level >= WarnLevel { + if logger.level() >= WarnLevel { entry := logger.newEntry() entry.Warnf(format, args...) logger.releaseEntry(entry) @@ -150,7 +151,7 @@ func (logger *Logger) Warningf(format string, args ...interface{}) { } func (logger *Logger) Errorf(format string, args ...interface{}) { - if logger.Level >= ErrorLevel { + if logger.level() >= ErrorLevel { entry := logger.newEntry() entry.Errorf(format, args...) logger.releaseEntry(entry) @@ -158,7 +159,7 @@ func (logger *Logger) Errorf(format string, args ...interface{}) { } func (logger *Logger) Fatalf(format string, args ...interface{}) { - if logger.Level >= FatalLevel { + if logger.level() >= FatalLevel { entry := logger.newEntry() entry.Fatalf(format, args...) logger.releaseEntry(entry) @@ -167,7 +168,7 @@ func (logger *Logger) Fatalf(format string, args ...interface{}) { } func (logger *Logger) Panicf(format string, args ...interface{}) { - if logger.Level >= PanicLevel { + if logger.level() >= PanicLevel { entry := logger.newEntry() entry.Panicf(format, args...) logger.releaseEntry(entry) @@ -175,7 +176,7 @@ func (logger *Logger) Panicf(format string, args ...interface{}) { } func (logger *Logger) Debug(args ...interface{}) { - if logger.Level >= DebugLevel { + if logger.level() >= DebugLevel { entry := logger.newEntry() entry.Debug(args...) logger.releaseEntry(entry) @@ -183,7 +184,7 @@ func (logger *Logger) Debug(args ...interface{}) { } func (logger *Logger) Info(args ...interface{}) { - if logger.Level >= InfoLevel { + if logger.level() >= InfoLevel { entry := logger.newEntry() entry.Info(args...) logger.releaseEntry(entry) @@ -197,7 +198,7 @@ func (logger *Logger) Print(args ...interface{}) { } func (logger *Logger) Warn(args ...interface{}) { - if logger.Level >= WarnLevel { + if logger.level() >= WarnLevel { entry := logger.newEntry() entry.Warn(args...) logger.releaseEntry(entry) @@ -205,7 +206,7 @@ func (logger *Logger) Warn(args ...interface{}) { } func (logger *Logger) Warning(args ...interface{}) { - if logger.Level >= WarnLevel { + if logger.level() >= WarnLevel { entry := logger.newEntry() entry.Warn(args...) logger.releaseEntry(entry) @@ -213,7 +214,7 @@ func (logger *Logger) Warning(args ...interface{}) { } func (logger *Logger) Error(args ...interface{}) { - if logger.Level >= ErrorLevel { + if logger.level() >= ErrorLevel { entry := logger.newEntry() entry.Error(args...) logger.releaseEntry(entry) @@ -221,7 +222,7 @@ func (logger *Logger) Error(args ...interface{}) { } func (logger *Logger) Fatal(args ...interface{}) { - if logger.Level >= FatalLevel { + if logger.level() >= FatalLevel { entry := logger.newEntry() entry.Fatal(args...) logger.releaseEntry(entry) @@ -230,7 +231,7 @@ func (logger *Logger) Fatal(args ...interface{}) { } func (logger *Logger) Panic(args ...interface{}) { - if logger.Level >= PanicLevel { + if logger.level() >= PanicLevel { entry := logger.newEntry() entry.Panic(args...) logger.releaseEntry(entry) @@ -238,7 +239,7 @@ func (logger *Logger) Panic(args ...interface{}) { } func (logger *Logger) Debugln(args ...interface{}) { - if logger.Level >= DebugLevel { + if logger.level() >= DebugLevel { entry := logger.newEntry() entry.Debugln(args...) logger.releaseEntry(entry) @@ -246,7 +247,7 @@ func (logger *Logger) Debugln(args ...interface{}) { } func (logger *Logger) Infoln(args ...interface{}) { - if logger.Level >= InfoLevel { + if logger.level() >= InfoLevel { entry := logger.newEntry() entry.Infoln(args...) logger.releaseEntry(entry) @@ -260,7 +261,7 @@ func (logger *Logger) Println(args ...interface{}) { } func (logger *Logger) Warnln(args ...interface{}) { - if logger.Level >= WarnLevel { + if logger.level() >= WarnLevel { entry := logger.newEntry() entry.Warnln(args...) logger.releaseEntry(entry) @@ -268,7 +269,7 @@ func (logger *Logger) Warnln(args ...interface{}) { } func (logger *Logger) Warningln(args ...interface{}) { - if logger.Level >= WarnLevel { + if logger.level() >= WarnLevel { entry := logger.newEntry() entry.Warnln(args...) logger.releaseEntry(entry) @@ -276,7 +277,7 @@ func (logger *Logger) Warningln(args ...interface{}) { } func (logger *Logger) Errorln(args ...interface{}) { - if logger.Level >= ErrorLevel { + if logger.level() >= ErrorLevel { entry := logger.newEntry() entry.Errorln(args...) logger.releaseEntry(entry) @@ -284,7 +285,7 @@ func (logger *Logger) Errorln(args ...interface{}) { } func (logger *Logger) Fatalln(args ...interface{}) { - if logger.Level >= FatalLevel { + if logger.level() >= FatalLevel { entry := logger.newEntry() entry.Fatalln(args...) logger.releaseEntry(entry) @@ -293,7 +294,7 @@ func (logger *Logger) Fatalln(args ...interface{}) { } func (logger *Logger) Panicln(args ...interface{}) { - if logger.Level >= PanicLevel { + if logger.level() >= PanicLevel { entry := logger.newEntry() entry.Panicln(args...) logger.releaseEntry(entry) @@ -306,3 +307,11 @@ func (logger *Logger) Panicln(args ...interface{}) { func (logger *Logger) SetNoLock() { logger.mu.Disable() } + +func (logger *Logger) level() Level { + return Level(atomic.LoadUint32((*uint32)(&logger.Level))) +} + +func (logger *Logger) setLevel(level Level) { + atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) +} diff --git a/vendor/github.com/Sirupsen/logrus/logrus.go b/vendor/github.com/sirupsen/logrus/logrus.go similarity index 99% rename from vendor/github.com/Sirupsen/logrus/logrus.go rename to vendor/github.com/sirupsen/logrus/logrus.go index e5966911..dd389997 100644 --- a/vendor/github.com/Sirupsen/logrus/logrus.go +++ b/vendor/github.com/sirupsen/logrus/logrus.go @@ -10,7 +10,7 @@ import ( type Fields map[string]interface{} // Level type -type Level uint8 +type Level uint32 // Convert the Level to a string. E.g. PanicLevel becomes "panic". func (level Level) String() string { diff --git a/vendor/github.com/Sirupsen/logrus/terminal_appengine.go b/vendor/github.com/sirupsen/logrus/terminal_appengine.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_appengine.go rename to vendor/github.com/sirupsen/logrus/terminal_appengine.go diff --git a/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/vendor/github.com/sirupsen/logrus/terminal_bsd.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_bsd.go rename to vendor/github.com/sirupsen/logrus/terminal_bsd.go diff --git a/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/vendor/github.com/sirupsen/logrus/terminal_linux.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_linux.go rename to vendor/github.com/sirupsen/logrus/terminal_linux.go diff --git a/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go b/vendor/github.com/sirupsen/logrus/terminal_notwindows.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_notwindows.go rename to vendor/github.com/sirupsen/logrus/terminal_notwindows.go diff --git a/vendor/github.com/Sirupsen/logrus/terminal_solaris.go b/vendor/github.com/sirupsen/logrus/terminal_solaris.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_solaris.go rename to vendor/github.com/sirupsen/logrus/terminal_solaris.go diff --git a/vendor/github.com/sirupsen/logrus/terminal_windows.go b/vendor/github.com/sirupsen/logrus/terminal_windows.go new file mode 100644 index 00000000..7a336307 --- /dev/null +++ b/vendor/github.com/sirupsen/logrus/terminal_windows.go @@ -0,0 +1,82 @@ +// Based on ssh/terminal: +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows,!appengine + +package logrus + +import ( + "bytes" + "errors" + "io" + "os" + "os/exec" + "strconv" + "strings" + "syscall" + "unsafe" +) + +var kernel32 = syscall.NewLazyDLL("kernel32.dll") + +var ( + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procSetConsoleMode = kernel32.NewProc("SetConsoleMode") +) + +const ( + enableProcessedOutput = 0x0001 + enableWrapAtEolOutput = 0x0002 + enableVirtualTerminalProcessing = 0x0004 +) + +func getVersion() (float64, error) { + stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{} + cmd := exec.Command("cmd", "ver") + cmd.Stdout = stdout + cmd.Stderr = stderr + err := cmd.Run() + if err != nil { + return -1, err + } + + // The output should be like "Microsoft Windows [Version XX.X.XXXXXX]" + version := strings.Replace(stdout.String(), "\n", "", -1) + version = strings.Replace(version, "\r\n", "", -1) + + x1 := strings.Index(version, "[Version") + + if x1 == -1 || strings.Index(version, "]") == -1 { + return -1, errors.New("Can't determine Windows version") + } + + return strconv.ParseFloat(version[x1+9:x1+13], 64) +} + +func init() { + ver, err := getVersion() + if err != nil { + return + } + + // Activate Virtual Processing for Windows CMD + // Info: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx + if ver >= 10 { + handle := syscall.Handle(os.Stderr.Fd()) + procSetConsoleMode.Call(uintptr(handle), enableProcessedOutput|enableWrapAtEolOutput|enableVirtualTerminalProcessing) + } +} + +// IsTerminal returns true if stderr's file descriptor is a terminal. +func IsTerminal(f io.Writer) bool { + switch v := f.(type) { + case *os.File: + var st uint32 + r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) + return r != 0 && e == 0 + default: + return false + } +} diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/text_formatter.go rename to vendor/github.com/sirupsen/logrus/text_formatter.go diff --git a/vendor/github.com/Sirupsen/logrus/writer.go b/vendor/github.com/sirupsen/logrus/writer.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/writer.go rename to vendor/github.com/sirupsen/logrus/writer.go