Update logrus to v1.0.1 (Sirupsen -> sirupsen)
| ... | ... |
@@ -4,10 +4,10 @@ import ( |
| 4 | 4 |
"net/http" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/api/types" |
| 9 | 8 |
"github.com/docker/docker/api/types/versions" |
| 10 | 9 |
"github.com/gorilla/mux" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
"google.golang.org/grpc" |
| 12 | 12 |
"google.golang.org/grpc/codes" |
| 13 | 13 |
) |
| ... | ... |
@@ -1,9 +1,9 @@ |
| 1 | 1 |
package server |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "github.com/Sirupsen/logrus" |
|
| 5 | 4 |
"github.com/docker/docker/api/server/httputils" |
| 6 | 5 |
"github.com/docker/docker/api/server/middleware" |
| 6 |
+ "github.com/sirupsen/logrus" |
|
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
// handlerWithGlobalMiddlewares wraps the handler function for a request with |
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"strings" |
| 13 | 13 |
"sync" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
apierrors "github.com/docker/docker/api/errors" |
| 17 | 16 |
"github.com/docker/docker/api/server/httputils" |
| 18 | 17 |
"github.com/docker/docker/api/types" |
| ... | ... |
@@ -24,6 +23,7 @@ import ( |
| 24 | 24 |
"github.com/docker/docker/pkg/streamformatter" |
| 25 | 25 |
units "github.com/docker/go-units" |
| 26 | 26 |
"github.com/pkg/errors" |
| 27 |
+ "github.com/sirupsen/logrus" |
|
| 27 | 28 |
"golang.org/x/net/context" |
| 28 | 29 |
) |
| 29 | 30 |
|
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"strconv" |
| 9 | 9 |
"syscall" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/api" |
| 13 | 12 |
"github.com/docker/docker/api/server/httputils" |
| 14 | 13 |
"github.com/docker/docker/api/types" |
| ... | ... |
@@ -19,6 +18,7 @@ import ( |
| 19 | 19 |
containerpkg "github.com/docker/docker/container" |
| 20 | 20 |
"github.com/docker/docker/pkg/ioutils" |
| 21 | 21 |
"github.com/docker/docker/pkg/signal" |
| 22 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 23 |
"golang.org/x/net/context" |
| 23 | 24 |
"golang.org/x/net/websocket" |
| 24 | 25 |
) |
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"net/http" |
| 8 | 8 |
"strconv" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/server/httputils" |
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/api/types/versions" |
| 14 | 13 |
"github.com/docker/docker/pkg/stdcopy" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
"golang.org/x/net/context" |
| 16 | 16 |
) |
| 17 | 17 |
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"strconv" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/api/errors" |
| 11 | 10 |
"github.com/docker/docker/api/server/httputils" |
| 12 | 11 |
basictypes "github.com/docker/docker/api/types" |
| ... | ... |
@@ -14,6 +13,7 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/api/types/filters" |
| 15 | 15 |
types "github.com/docker/docker/api/types/swarm" |
| 16 | 16 |
"github.com/docker/docker/api/types/versions" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 18 |
"golang.org/x/net/context" |
| 18 | 19 |
) |
| 19 | 20 |
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/api" |
| 11 | 10 |
"github.com/docker/docker/api/errors" |
| 12 | 11 |
"github.com/docker/docker/api/server/httputils" |
| ... | ... |
@@ -18,6 +17,7 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/api/types/versions" |
| 19 | 19 |
"github.com/docker/docker/pkg/ioutils" |
| 20 | 20 |
pkgerrors "github.com/pkg/errors" |
| 21 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 22 |
"golang.org/x/net/context" |
| 22 | 23 |
) |
| 23 | 24 |
|
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"net/http" |
| 8 | 8 |
"strings" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/errors" |
| 12 | 11 |
"github.com/docker/docker/api/server/httputils" |
| 13 | 12 |
"github.com/docker/docker/api/server/middleware" |
| ... | ... |
@@ -15,6 +14,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/api/server/router/debug" |
| 16 | 16 |
"github.com/docker/docker/dockerversion" |
| 17 | 17 |
"github.com/gorilla/mux" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 19 |
"golang.org/x/net/context" |
| 19 | 20 |
) |
| 20 | 21 |
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
"github.com/docker/docker/api/types/backend" |
| 15 | 14 |
"github.com/docker/docker/api/types/container" |
| ... | ... |
@@ -26,6 +25,7 @@ import ( |
| 26 | 26 |
"github.com/docker/docker/pkg/system" |
| 27 | 27 |
"github.com/moby/buildkit/session" |
| 28 | 28 |
"github.com/pkg/errors" |
| 29 |
+ "github.com/sirupsen/logrus" |
|
| 29 | 30 |
"golang.org/x/net/context" |
| 30 | 31 |
"golang.org/x/sync/syncmap" |
| 31 | 32 |
) |
| ... | ... |
@@ -4,13 +4,13 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"io" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/api/types" |
| 9 | 8 |
"github.com/docker/docker/api/types/container" |
| 10 | 9 |
"github.com/docker/docker/builder" |
| 11 | 10 |
containerpkg "github.com/docker/docker/container" |
| 12 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 13 | 12 |
"github.com/pkg/errors" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
"golang.org/x/net/context" |
| 15 | 15 |
) |
| 16 | 16 |
|
| ... | ... |
@@ -17,7 +17,6 @@ import ( |
| 17 | 17 |
"strings" |
| 18 | 18 |
"time" |
| 19 | 19 |
|
| 20 |
- "github.com/Sirupsen/logrus" |
|
| 21 | 20 |
"github.com/docker/docker/api" |
| 22 | 21 |
"github.com/docker/docker/api/types/container" |
| 23 | 22 |
"github.com/docker/docker/api/types/strslice" |
| ... | ... |
@@ -29,6 +28,7 @@ import ( |
| 29 | 29 |
"github.com/docker/docker/pkg/system" |
| 30 | 30 |
"github.com/docker/go-connections/nat" |
| 31 | 31 |
"github.com/pkg/errors" |
| 32 |
+ "github.com/sirupsen/logrus" |
|
| 32 | 33 |
) |
| 33 | 34 |
|
| 34 | 35 |
// ENV foo bar |
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"strconv" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/api/types/backend" |
| 9 | 8 |
"github.com/docker/docker/builder" |
| 10 | 9 |
"github.com/docker/docker/builder/remotecontext" |
| 11 | 10 |
dockerimage "github.com/docker/docker/image" |
| 12 | 11 |
"github.com/pkg/errors" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
"golang.org/x/net/context" |
| 14 | 14 |
) |
| 15 | 15 |
|
| ... | ... |
@@ -1,9 +1,9 @@ |
| 1 | 1 |
package dockerfile |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "github.com/Sirupsen/logrus" |
|
| 5 | 4 |
"github.com/docker/docker/api/types/container" |
| 6 | 5 |
"github.com/docker/docker/builder" |
| 6 |
+ "github.com/sirupsen/logrus" |
|
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
// ImageProber exposes an Image cache to the Builder. It supports resetting a |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"sync" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/boltdb/bolt" |
| 13 | 12 |
"github.com/docker/docker/builder" |
| 14 | 13 |
"github.com/docker/docker/builder/remotecontext" |
| ... | ... |
@@ -16,6 +15,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/pkg/stringid" |
| 17 | 17 |
"github.com/moby/buildkit/session/filesync" |
| 18 | 18 |
"github.com/pkg/errors" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 20 |
"github.com/tonistiigi/fsutil" |
| 20 | 21 |
"golang.org/x/net/context" |
| 21 | 22 |
"golang.org/x/sync/singleflight" |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"path/filepath" |
| 9 | 9 |
"strings" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/api/types/backend" |
| 13 | 12 |
"github.com/docker/docker/builder" |
| 14 | 13 |
"github.com/docker/docker/builder/dockerfile/parser" |
| ... | ... |
@@ -17,6 +16,7 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/pkg/symlink" |
| 18 | 18 |
"github.com/docker/docker/pkg/urlutil" |
| 19 | 19 |
"github.com/pkg/errors" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 21 |
) |
| 21 | 22 |
|
| 22 | 23 |
// ClientSessionRemote is identifier for client-session context transport |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/distribution/uuid" |
| 14 | 13 |
"github.com/docker/docker/api" |
| 15 | 14 |
apiserver "github.com/docker/docker/api/server" |
| ... | ... |
@@ -51,6 +50,7 @@ import ( |
| 51 | 51 |
swarmapi "github.com/docker/swarmkit/api" |
| 52 | 52 |
"github.com/moby/buildkit/session" |
| 53 | 53 |
"github.com/pkg/errors" |
| 54 |
+ "github.com/sirupsen/logrus" |
|
| 54 | 55 |
"github.com/spf13/pflag" |
| 55 | 56 |
) |
| 56 | 57 |
|
| ... | ... |
@@ -3,10 +3,10 @@ package main |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/docker/daemon/config" |
| 8 | 7 |
"github.com/docker/docker/pkg/testutil" |
| 9 | 8 |
"github.com/docker/docker/pkg/testutil/tempfile" |
| 9 |
+ "github.com/sirupsen/logrus" |
|
| 10 | 10 |
"github.com/spf13/pflag" |
| 11 | 11 |
"github.com/stretchr/testify/assert" |
| 12 | 12 |
"github.com/stretchr/testify/require" |
| ... | ... |
@@ -6,12 +6,12 @@ import ( |
| 6 | 6 |
"path/filepath" |
| 7 | 7 |
"runtime" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/cli" |
| 11 | 10 |
"github.com/docker/docker/daemon/config" |
| 12 | 11 |
"github.com/docker/docker/dockerversion" |
| 13 | 12 |
"github.com/docker/docker/pkg/reexec" |
| 14 | 13 |
"github.com/docker/docker/pkg/term" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
"github.com/spf13/cobra" |
| 16 | 16 |
) |
| 17 | 17 |
|
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"os" |
| 6 | 6 |
"path/filepath" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
cliconfig "github.com/docker/docker/cli/config" |
| 10 | 9 |
"github.com/docker/docker/daemon/config" |
| 11 | 10 |
"github.com/docker/docker/opts" |
| 12 | 11 |
"github.com/docker/go-connections/tlsconfig" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
"github.com/spf13/pflag" |
| 14 | 14 |
) |
| 15 | 15 |
|
| ... | ... |
@@ -15,7 +15,6 @@ import ( |
| 15 | 15 |
"syscall" |
| 16 | 16 |
"time" |
| 17 | 17 |
|
| 18 |
- "github.com/Sirupsen/logrus" |
|
| 19 | 18 |
containertypes "github.com/docker/docker/api/types/container" |
| 20 | 19 |
mounttypes "github.com/docker/docker/api/types/mount" |
| 21 | 20 |
networktypes "github.com/docker/docker/api/types/network" |
| ... | ... |
@@ -44,6 +43,7 @@ import ( |
| 44 | 44 |
"github.com/docker/libnetwork/options" |
| 45 | 45 |
"github.com/docker/libnetwork/types" |
| 46 | 46 |
agentexec "github.com/docker/swarmkit/agent/exec" |
| 47 |
+ "github.com/sirupsen/logrus" |
|
| 47 | 48 |
"golang.org/x/net/context" |
| 48 | 49 |
) |
| 49 | 50 |
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"path/filepath" |
| 10 | 10 |
"strings" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
containertypes "github.com/docker/docker/api/types/container" |
| 15 | 14 |
mounttypes "github.com/docker/docker/api/types/mount" |
| ... | ... |
@@ -20,6 +19,7 @@ import ( |
| 20 | 20 |
"github.com/docker/docker/pkg/system" |
| 21 | 21 |
"github.com/docker/docker/volume" |
| 22 | 22 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 23 |
+ "github.com/sirupsen/logrus" |
|
| 23 | 24 |
"golang.org/x/sys/unix" |
| 24 | 25 |
) |
| 25 | 26 |
|
| ... | ... |
@@ -6,10 +6,10 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
"golang.org/x/net/context" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/pkg/pools" |
| 11 | 10 |
"github.com/docker/docker/pkg/promise" |
| 12 | 11 |
"github.com/docker/docker/pkg/term" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
var defaultEscapeSequence = []byte{16, 17} // ctrl-p, ctrl-q
|
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/libcontainerd" |
| 12 | 11 |
"github.com/docker/docker/pkg/broadcaster" |
| 13 | 12 |
"github.com/docker/docker/pkg/ioutils" |
| 14 | 13 |
"github.com/docker/docker/pkg/pools" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
// Config holds information about I/O streams managed together. |
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/api/types/network" |
| 12 | 11 |
"github.com/docker/go-connections/nat" |
| 13 | 12 |
"github.com/hashicorp/go-memdb" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
const ( |
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/api/errors" |
| 10 | 9 |
"github.com/docker/docker/api/types/backend" |
| 11 | 10 |
"github.com/docker/docker/container" |
| ... | ... |
@@ -13,6 +12,7 @@ import ( |
| 13 | 13 |
"github.com/docker/docker/daemon/logger" |
| 14 | 14 |
"github.com/docker/docker/pkg/stdcopy" |
| 15 | 15 |
"github.com/docker/docker/pkg/term" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 17 |
) |
| 17 | 18 |
|
| 18 | 19 |
// ContainerAttach attaches to logs according to the config passed in. See ContainerAttachConfig. |
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"io" |
| 5 | 5 |
"runtime" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/distribution/reference" |
| 9 | 8 |
"github.com/docker/docker/api/types" |
| 10 | 9 |
"github.com/docker/docker/api/types/backend" |
| ... | ... |
@@ -15,6 +14,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/pkg/stringid" |
| 16 | 16 |
"github.com/docker/docker/registry" |
| 17 | 17 |
"github.com/pkg/errors" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 19 |
"golang.org/x/net/context" |
| 19 | 20 |
) |
| 20 | 21 |
|
| ... | ... |
@@ -46,7 +46,6 @@ import ( |
| 46 | 46 |
"sync" |
| 47 | 47 |
"time" |
| 48 | 48 |
|
| 49 |
- "github.com/Sirupsen/logrus" |
|
| 50 | 49 |
"github.com/docker/docker/api/types/network" |
| 51 | 50 |
types "github.com/docker/docker/api/types/swarm" |
| 52 | 51 |
"github.com/docker/docker/daemon/cluster/controllers/plugin" |
| ... | ... |
@@ -56,6 +55,7 @@ import ( |
| 56 | 56 |
swarmapi "github.com/docker/swarmkit/api" |
| 57 | 57 |
swarmnode "github.com/docker/swarmkit/node" |
| 58 | 58 |
"github.com/pkg/errors" |
| 59 |
+ "github.com/sirupsen/logrus" |
|
| 59 | 60 |
"golang.org/x/net/context" |
| 60 | 61 |
) |
| 61 | 62 |
|
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"io/ioutil" |
| 6 | 6 |
"net/http" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/distribution/reference" |
| 10 | 9 |
enginetypes "github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/api/types/swarm/runtime" |
| ... | ... |
@@ -14,6 +13,7 @@ import ( |
| 14 | 14 |
"github.com/docker/swarmkit/api" |
| 15 | 15 |
"github.com/gogo/protobuf/proto" |
| 16 | 16 |
"github.com/pkg/errors" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 18 |
"golang.org/x/net/context" |
| 18 | 19 |
) |
| 19 | 20 |
|
| ... | ... |
@@ -9,13 +9,13 @@ import ( |
| 9 | 9 |
"testing" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/distribution/reference" |
| 14 | 13 |
enginetypes "github.com/docker/docker/api/types" |
| 15 | 14 |
"github.com/docker/docker/api/types/swarm/runtime" |
| 16 | 15 |
"github.com/docker/docker/pkg/pubsub" |
| 17 | 16 |
"github.com/docker/docker/plugin" |
| 18 | 17 |
"github.com/docker/docker/plugin/v2" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 19 |
"golang.org/x/net/context" |
| 20 | 20 |
) |
| 21 | 21 |
|
| ... | ... |
@@ -5,12 +5,12 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
container "github.com/docker/docker/api/types/container" |
| 10 | 9 |
mounttypes "github.com/docker/docker/api/types/mount" |
| 11 | 10 |
types "github.com/docker/docker/api/types/swarm" |
| 12 | 11 |
swarmapi "github.com/docker/swarmkit/api" |
| 13 | 12 |
gogotypes "github.com/gogo/protobuf/types" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
|
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"syscall" |
| 13 | 13 |
"time" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
"github.com/docker/distribution/reference" |
| 17 | 16 |
"github.com/docker/docker/api/types" |
| 18 | 17 |
"github.com/docker/docker/api/types/backend" |
| ... | ... |
@@ -28,6 +27,7 @@ import ( |
| 28 | 28 |
"github.com/docker/swarmkit/log" |
| 29 | 29 |
gogotypes "github.com/gogo/protobuf/types" |
| 30 | 30 |
"github.com/opencontainers/go-digest" |
| 31 |
+ "github.com/sirupsen/logrus" |
|
| 31 | 32 |
"golang.org/x/net/context" |
| 32 | 33 |
"golang.org/x/time/rate" |
| 33 | 34 |
) |
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"sort" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/api/types" |
| 10 | 9 |
"github.com/docker/docker/api/types/filters" |
| 11 | 10 |
"github.com/docker/docker/api/types/network" |
| ... | ... |
@@ -19,6 +18,7 @@ import ( |
| 19 | 19 |
"github.com/docker/swarmkit/agent/exec" |
| 20 | 20 |
"github.com/docker/swarmkit/api" |
| 21 | 21 |
"github.com/docker/swarmkit/api/naming" |
| 22 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 23 |
"golang.org/x/net/context" |
| 23 | 24 |
) |
| 24 | 25 |
|
| ... | ... |
@@ -3,7 +3,6 @@ package cluster |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
apierrors "github.com/docker/docker/api/errors" |
| 8 | 7 |
apitypes "github.com/docker/docker/api/types" |
| 9 | 8 |
"github.com/docker/docker/api/types/network" |
| ... | ... |
@@ -12,6 +11,7 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/runconfig" |
| 13 | 13 |
swarmapi "github.com/docker/swarmkit/api" |
| 14 | 14 |
"github.com/pkg/errors" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 16 |
"golang.org/x/net/context" |
| 16 | 17 |
) |
| 17 | 18 |
|
| ... | ... |
@@ -8,13 +8,13 @@ import ( |
| 8 | 8 |
"sync" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
types "github.com/docker/docker/api/types/swarm" |
| 13 | 12 |
"github.com/docker/docker/daemon/cluster/executor/container" |
| 14 | 13 |
lncluster "github.com/docker/libnetwork/cluster" |
| 15 | 14 |
swarmapi "github.com/docker/swarmkit/api" |
| 16 | 15 |
swarmnode "github.com/docker/swarmkit/node" |
| 17 | 16 |
"github.com/pkg/errors" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 18 |
"golang.org/x/net/context" |
| 19 | 19 |
"google.golang.org/grpc" |
| 20 | 20 |
) |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/distribution/reference" |
| 15 | 14 |
apierrors "github.com/docker/docker/api/errors" |
| 16 | 15 |
apitypes "github.com/docker/docker/api/types" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
swarmapi "github.com/docker/swarmkit/api" |
| 23 | 23 |
gogotypes "github.com/gogo/protobuf/types" |
| 24 | 24 |
"github.com/pkg/errors" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
"golang.org/x/net/context" |
| 26 | 27 |
) |
| 27 | 28 |
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
apierrors "github.com/docker/docker/api/errors" |
| 11 | 10 |
apitypes "github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/api/types/filters" |
| ... | ... |
@@ -18,6 +17,7 @@ import ( |
| 18 | 18 |
"github.com/docker/swarmkit/manager/encryption" |
| 19 | 19 |
swarmnode "github.com/docker/swarmkit/node" |
| 20 | 20 |
"github.com/pkg/errors" |
| 21 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 22 |
"golang.org/x/net/context" |
| 22 | 23 |
) |
| 23 | 24 |
|
| ... | ... |
@@ -12,13 +12,13 @@ import ( |
| 12 | 12 |
"strings" |
| 13 | 13 |
"sync" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
daemondiscovery "github.com/docker/docker/daemon/discovery" |
| 17 | 16 |
"github.com/docker/docker/opts" |
| 18 | 17 |
"github.com/docker/docker/pkg/authorization" |
| 19 | 18 |
"github.com/docker/docker/pkg/discovery" |
| 20 | 19 |
"github.com/docker/docker/registry" |
| 21 | 20 |
"github.com/imdario/mergo" |
| 21 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 22 |
"github.com/spf13/pflag" |
| 23 | 23 |
) |
| 24 | 24 |
|
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
derr "github.com/docker/docker/api/errors" |
| 15 | 14 |
containertypes "github.com/docker/docker/api/types/container" |
| 16 | 15 |
networktypes "github.com/docker/docker/api/types/network" |
| ... | ... |
@@ -24,6 +23,7 @@ import ( |
| 24 | 24 |
"github.com/docker/libnetwork/netlabel" |
| 25 | 25 |
"github.com/docker/libnetwork/options" |
| 26 | 26 |
"github.com/docker/libnetwork/types" |
| 27 |
+ "github.com/sirupsen/logrus" |
|
| 27 | 28 |
) |
| 28 | 29 |
|
| 29 | 30 |
var ( |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/docker/container" |
| 16 | 15 |
"github.com/docker/docker/daemon/links" |
| 17 | 16 |
"github.com/docker/docker/pkg/idtools" |
| ... | ... |
@@ -21,6 +20,7 @@ import ( |
| 21 | 21 |
"github.com/docker/libnetwork" |
| 22 | 22 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 23 | 23 |
"github.com/pkg/errors" |
| 24 |
+ "github.com/sirupsen/logrus" |
|
| 24 | 25 |
"golang.org/x/sys/unix" |
| 25 | 26 |
) |
| 26 | 27 |
|
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"io/ioutil" |
| 6 | 6 |
"os" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/container" |
| 10 | 9 |
"github.com/docker/docker/pkg/system" |
| 11 | 10 |
"github.com/docker/libnetwork" |
| 12 | 11 |
"github.com/pkg/errors" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/pkg/errors" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
apierrors "github.com/docker/docker/api/errors" |
| 14 | 13 |
"github.com/docker/docker/api/types" |
| 15 | 14 |
containertypes "github.com/docker/docker/api/types/container" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/pkg/system" |
| 23 | 23 |
"github.com/docker/docker/runconfig" |
| 24 | 24 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
) |
| 26 | 27 |
|
| 27 | 28 |
// CreateManagedContainer creates a container that is managed by a Service |
| ... | ... |
@@ -7,12 +7,12 @@ import ( |
| 7 | 7 |
"os" |
| 8 | 8 |
"path/filepath" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
containertypes "github.com/docker/docker/api/types/container" |
| 12 | 11 |
mounttypes "github.com/docker/docker/api/types/mount" |
| 13 | 12 |
"github.com/docker/docker/container" |
| 14 | 13 |
"github.com/docker/docker/pkg/stringid" |
| 15 | 14 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
// createContainerPlatformSpecificSettings performs platform specific container create functionality |
| ... | ... |
@@ -18,7 +18,6 @@ import ( |
| 18 | 18 |
"sync" |
| 19 | 19 |
"time" |
| 20 | 20 |
|
| 21 |
- "github.com/Sirupsen/logrus" |
|
| 22 | 21 |
containerd "github.com/containerd/containerd/api/grpc/types" |
| 23 | 22 |
"github.com/docker/docker/api" |
| 24 | 23 |
"github.com/docker/docker/api/types" |
| ... | ... |
@@ -31,6 +30,7 @@ import ( |
| 31 | 31 |
"github.com/docker/docker/daemon/exec" |
| 32 | 32 |
"github.com/docker/docker/daemon/logger" |
| 33 | 33 |
"github.com/docker/docker/opts" |
| 34 |
+ "github.com/sirupsen/logrus" |
|
| 34 | 35 |
// register graph drivers |
| 35 | 36 |
_ "github.com/docker/docker/daemon/graphdriver/register" |
| 36 | 37 |
"github.com/docker/docker/daemon/initlayer" |
| ... | ... |
@@ -8,9 +8,9 @@ import ( |
| 8 | 8 |
"regexp" |
| 9 | 9 |
"strings" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/pkg/fileutils" |
| 13 | 12 |
"github.com/docker/docker/pkg/mount" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// On Linux, plugins use a static path for storing execution state, |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"net" |
| 8 | 8 |
"strconv" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
containertypes "github.com/docker/docker/api/types/container" |
| 13 | 12 |
"github.com/docker/docker/container" |
| ... | ... |
@@ -27,6 +26,7 @@ import ( |
| 27 | 27 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 28 | 28 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 29 | 29 |
"github.com/pkg/errors" |
| 30 |
+ "github.com/sirupsen/logrus" |
|
| 30 | 31 |
) |
| 31 | 32 |
|
| 32 | 33 |
//#include <zone.h> |
| ... | ... |
@@ -16,7 +16,6 @@ import ( |
| 16 | 16 |
"strings" |
| 17 | 17 |
"time" |
| 18 | 18 |
|
| 19 |
- "github.com/Sirupsen/logrus" |
|
| 20 | 19 |
"github.com/docker/docker/api/types" |
| 21 | 20 |
"github.com/docker/docker/api/types/blkiodev" |
| 22 | 21 |
pblkiodev "github.com/docker/docker/api/types/blkiodev" |
| ... | ... |
@@ -44,6 +43,7 @@ import ( |
| 44 | 44 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 45 | 45 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 46 | 46 |
"github.com/pkg/errors" |
| 47 |
+ "github.com/sirupsen/logrus" |
|
| 47 | 48 |
"github.com/vishvananda/netlink" |
| 48 | 49 |
"golang.org/x/sys/unix" |
| 49 | 50 |
) |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"syscall" |
| 9 | 9 |
|
| 10 | 10 |
"github.com/Microsoft/hcsshim" |
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
containertypes "github.com/docker/docker/api/types/container" |
| 14 | 13 |
"github.com/docker/docker/container" |
| ... | ... |
@@ -28,6 +27,7 @@ import ( |
| 28 | 28 |
"github.com/docker/libnetwork/netlabel" |
| 29 | 29 |
"github.com/docker/libnetwork/options" |
| 30 | 30 |
blkiodev "github.com/opencontainers/runc/libcontainer/configs" |
| 31 |
+ "github.com/sirupsen/logrus" |
|
| 31 | 32 |
"golang.org/x/sys/windows" |
| 32 | 33 |
) |
| 33 | 34 |
|
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
apierrors "github.com/docker/docker/api/errors" |
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/container" |
| ... | ... |
@@ -15,6 +14,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/pkg/system" |
| 16 | 16 |
volumestore "github.com/docker/docker/volume/store" |
| 17 | 17 |
"github.com/pkg/errors" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 19 |
) |
| 19 | 20 |
|
| 20 | 21 |
// ContainerRm removes the container id from the filesystem. An error |
| ... | ... |
@@ -6,13 +6,13 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
"golang.org/x/net/context" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/api/types/filters" |
| 12 | 11 |
"github.com/docker/docker/layer" |
| 13 | 12 |
"github.com/docker/docker/pkg/directory" |
| 14 | 13 |
"github.com/docker/docker/volume" |
| 15 | 14 |
"github.com/opencontainers/go-digest" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
func (daemon *Daemon) getLayerRefs(platform string) map[layer.ChainID]int {
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/api/types/events" |
| 11 | 10 |
"github.com/docker/docker/api/types/filters" |
| 12 | 11 |
"github.com/docker/docker/container" |
| ... | ... |
@@ -14,6 +13,7 @@ import ( |
| 14 | 14 |
"github.com/docker/libnetwork" |
| 15 | 15 |
swarmapi "github.com/docker/swarmkit/api" |
| 16 | 16 |
gogotypes "github.com/gogo/protobuf/types" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 18 |
) |
| 18 | 19 |
|
| 19 | 20 |
var ( |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"golang.org/x/net/context" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/api/errors" |
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
"github.com/docker/docker/api/types/strslice" |
| ... | ... |
@@ -19,6 +18,7 @@ import ( |
| 19 | 19 |
"github.com/docker/docker/pkg/pools" |
| 20 | 20 |
"github.com/docker/docker/pkg/signal" |
| 21 | 21 |
"github.com/docker/docker/pkg/term" |
| 22 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 23 |
) |
| 23 | 24 |
|
| 24 | 25 |
// Seconds to wait after sending TERM before trying KILL |
| ... | ... |
@@ -4,10 +4,10 @@ import ( |
| 4 | 4 |
"runtime" |
| 5 | 5 |
"sync" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/container/stream" |
| 9 | 8 |
"github.com/docker/docker/libcontainerd" |
| 10 | 9 |
"github.com/docker/docker/pkg/stringid" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// Config holds the configurations for execs. The Daemon keeps |
| ... | ... |
@@ -35,7 +35,6 @@ import ( |
| 35 | 35 |
"sync" |
| 36 | 36 |
"time" |
| 37 | 37 |
|
| 38 |
- "github.com/Sirupsen/logrus" |
|
| 39 | 38 |
"github.com/docker/docker/daemon/graphdriver" |
| 40 | 39 |
"github.com/docker/docker/pkg/archive" |
| 41 | 40 |
"github.com/docker/docker/pkg/chrootarchive" |
| ... | ... |
@@ -47,6 +46,7 @@ import ( |
| 47 | 47 |
rsystem "github.com/opencontainers/runc/libcontainer/system" |
| 48 | 48 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 49 | 49 |
"github.com/pkg/errors" |
| 50 |
+ "github.com/sirupsen/logrus" |
|
| 50 | 51 |
"github.com/vbatts/tar-split/tar/storage" |
| 51 | 52 |
"golang.org/x/sys/unix" |
| 52 | 53 |
) |
| ... | ... |
@@ -26,7 +26,6 @@ import ( |
| 26 | 26 |
"sync" |
| 27 | 27 |
"unsafe" |
| 28 | 28 |
|
| 29 |
- "github.com/Sirupsen/logrus" |
|
| 30 | 29 |
"github.com/docker/docker/daemon/graphdriver" |
| 31 | 30 |
"github.com/docker/docker/pkg/idtools" |
| 32 | 31 |
"github.com/docker/docker/pkg/mount" |
| ... | ... |
@@ -34,6 +33,7 @@ import ( |
| 34 | 34 |
"github.com/docker/docker/pkg/system" |
| 35 | 35 |
"github.com/docker/go-units" |
| 36 | 36 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 37 |
+ "github.com/sirupsen/logrus" |
|
| 37 | 38 |
"golang.org/x/sys/unix" |
| 38 | 39 |
) |
| 39 | 40 |
|
| ... | ... |
@@ -18,7 +18,6 @@ import ( |
| 18 | 18 |
"sync" |
| 19 | 19 |
"time" |
| 20 | 20 |
|
| 21 |
- "github.com/Sirupsen/logrus" |
|
| 22 | 21 |
"github.com/docker/docker/daemon/graphdriver" |
| 23 | 22 |
"github.com/docker/docker/dockerversion" |
| 24 | 23 |
"github.com/docker/docker/pkg/devicemapper" |
| ... | ... |
@@ -29,6 +28,7 @@ import ( |
| 29 | 29 |
units "github.com/docker/go-units" |
| 30 | 30 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 31 | 31 |
"github.com/pkg/errors" |
| 32 |
+ "github.com/sirupsen/logrus" |
|
| 32 | 33 |
"golang.org/x/sys/unix" |
| 33 | 34 |
) |
| 34 | 35 |
|
| ... | ... |
@@ -4,11 +4,11 @@ import ( |
| 4 | 4 |
"io" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/pkg/archive" |
| 9 | 8 |
"github.com/docker/docker/pkg/chrootarchive" |
| 10 | 9 |
"github.com/docker/docker/pkg/idtools" |
| 11 | 10 |
"github.com/docker/docker/pkg/ioutils" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
var ( |
| ... | ... |
@@ -32,13 +32,13 @@ import ( |
| 32 | 32 |
"time" |
| 33 | 33 |
|
| 34 | 34 |
"github.com/Microsoft/hcsshim" |
| 35 |
- "github.com/Sirupsen/logrus" |
|
| 36 | 35 |
"github.com/docker/docker/daemon/graphdriver" |
| 37 | 36 |
"github.com/docker/docker/pkg/archive" |
| 38 | 37 |
"github.com/docker/docker/pkg/idtools" |
| 39 | 38 |
"github.com/docker/docker/pkg/ioutils" |
| 40 | 39 |
"github.com/docker/docker/pkg/system" |
| 41 | 40 |
"github.com/jhowardmsft/opengcs/gogcs/client" |
| 41 |
+ "github.com/sirupsen/logrus" |
|
| 42 | 42 |
) |
| 43 | 43 |
|
| 44 | 44 |
// init registers this driver to the register. It gets initialised by the |
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"path" |
| 13 | 13 |
"strconv" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
"github.com/docker/docker/daemon/graphdriver" |
| 17 | 16 |
"github.com/docker/docker/daemon/graphdriver/overlayutils" |
| 18 | 17 |
"github.com/docker/docker/pkg/archive" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/pkg/mount" |
| 23 | 23 |
"github.com/docker/docker/pkg/system" |
| 24 | 24 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
"golang.org/x/sys/unix" |
| 26 | 27 |
) |
| 27 | 28 |
|
| ... | ... |
@@ -24,7 +24,6 @@ import ( |
| 24 | 24 |
"github.com/Microsoft/go-winio/archive/tar" |
| 25 | 25 |
"github.com/Microsoft/go-winio/backuptar" |
| 26 | 26 |
"github.com/Microsoft/hcsshim" |
| 27 |
- "github.com/Sirupsen/logrus" |
|
| 28 | 27 |
"github.com/docker/docker/daemon/graphdriver" |
| 29 | 28 |
"github.com/docker/docker/pkg/archive" |
| 30 | 29 |
"github.com/docker/docker/pkg/idtools" |
| ... | ... |
@@ -33,6 +32,7 @@ import ( |
| 33 | 33 |
"github.com/docker/docker/pkg/reexec" |
| 34 | 34 |
"github.com/docker/docker/pkg/system" |
| 35 | 35 |
units "github.com/docker/go-units" |
| 36 |
+ "github.com/sirupsen/logrus" |
|
| 36 | 37 |
"golang.org/x/sys/windows" |
| 37 | 38 |
) |
| 38 | 39 |
|
| ... | ... |
@@ -12,13 +12,13 @@ import ( |
| 12 | 12 |
"sync" |
| 13 | 13 |
"time" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
"github.com/docker/docker/daemon/graphdriver" |
| 17 | 16 |
"github.com/docker/docker/pkg/idtools" |
| 18 | 17 |
"github.com/docker/docker/pkg/mount" |
| 19 | 18 |
"github.com/docker/docker/pkg/parsers" |
| 20 | 19 |
zfs "github.com/mistifyio/go-zfs" |
| 21 | 20 |
"github.com/opencontainers/selinux/go-selinux/label" |
| 21 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 22 |
"golang.org/x/sys/unix" |
| 23 | 23 |
) |
| 24 | 24 |
|
| ... | ... |
@@ -10,12 +10,12 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"golang.org/x/net/context" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/docker/api/types" |
| 15 | 14 |
containertypes "github.com/docker/docker/api/types/container" |
| 16 | 15 |
"github.com/docker/docker/api/types/strslice" |
| 17 | 16 |
"github.com/docker/docker/container" |
| 18 | 17 |
"github.com/docker/docker/daemon/exec" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 19 |
) |
| 20 | 20 |
|
| 21 | 21 |
const ( |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api" |
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/cli/debug" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/registry" |
| 23 | 23 |
"github.com/docker/docker/volume/drivers" |
| 24 | 24 |
"github.com/docker/go-connections/sockets" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
) |
| 26 | 27 |
|
| 27 | 28 |
// SystemInfo returns information about the host server the daemon is running on. |
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"os/exec" |
| 8 | 8 |
"strings" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/dockerversion" |
| 13 | 12 |
"github.com/docker/docker/pkg/sysinfo" |
| 14 | 13 |
"github.com/pkg/errors" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
// FillPlatformInfo fills the platform related info. |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
"strconv" |
| 8 | 8 |
"strings" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/api/types/filters" |
| 13 | 12 |
"github.com/docker/docker/container" |
| 14 | 13 |
"github.com/docker/docker/image" |
| 15 | 14 |
"github.com/docker/docker/volume" |
| 16 | 15 |
"github.com/docker/go-connections/nat" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
var acceptedVolumeFilterTags = map[string]bool{
|
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
"sync" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/types/plugins/logdriver" |
| 12 | 11 |
"github.com/docker/docker/pkg/plugingetter" |
| 13 | 12 |
"github.com/pkg/errors" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// pluginAdapter takes a plugin and implements the Logger interface for logger |
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
"sync" |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/aws/aws-sdk-go/aws" |
| 18 | 17 |
"github.com/aws/aws-sdk-go/aws/awserr" |
| 19 | 18 |
"github.com/aws/aws-sdk-go/aws/ec2metadata" |
| ... | ... |
@@ -25,6 +24,7 @@ import ( |
| 25 | 25 |
"github.com/docker/docker/dockerversion" |
| 26 | 26 |
"github.com/docker/docker/pkg/templates" |
| 27 | 27 |
"github.com/pkg/errors" |
| 28 |
+ "github.com/sirupsen/logrus" |
|
| 28 | 29 |
) |
| 29 | 30 |
|
| 30 | 31 |
const ( |
| ... | ... |
@@ -11,13 +11,13 @@ import ( |
| 11 | 11 |
"strings" |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/docker/daemon/logger" |
| 16 | 15 |
"github.com/docker/docker/daemon/logger/loggerutils" |
| 17 | 16 |
"github.com/docker/docker/pkg/urlutil" |
| 18 | 17 |
"github.com/docker/go-units" |
| 19 | 18 |
"github.com/fluent/fluent-logger-golang/fluent" |
| 20 | 19 |
"github.com/pkg/errors" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 21 |
) |
| 22 | 22 |
|
| 23 | 23 |
type fluentd struct {
|
| ... | ... |
@@ -5,9 +5,9 @@ package gcplogs |
| 5 | 5 |
import ( |
| 6 | 6 |
"os" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/dockerversion" |
| 10 | 9 |
"github.com/docker/docker/pkg/homedir" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// ensureHomeIfIAmStatic ensure $HOME to be set if dockerversion.IAmStatic is "true". |
| ... | ... |
@@ -14,10 +14,10 @@ import ( |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 | 16 |
"github.com/Graylog2/go-gelf/gelf" |
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/docker/docker/daemon/logger" |
| 19 | 18 |
"github.com/docker/docker/daemon/logger/loggerutils" |
| 20 | 19 |
"github.com/docker/docker/pkg/urlutil" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 21 |
) |
| 22 | 22 |
|
| 23 | 23 |
const name = "gelf" |
| ... | ... |
@@ -9,10 +9,10 @@ import ( |
| 9 | 9 |
"sync" |
| 10 | 10 |
"unicode" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/coreos/go-systemd/journal" |
| 14 | 13 |
"github.com/docker/docker/daemon/logger" |
| 15 | 14 |
"github.com/docker/docker/daemon/logger/loggerutils" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
const name = "journald" |
| ... | ... |
@@ -155,10 +155,10 @@ import ( |
| 155 | 155 |
"time" |
| 156 | 156 |
"unsafe" |
| 157 | 157 |
|
| 158 |
- "github.com/Sirupsen/logrus" |
|
| 159 | 158 |
"github.com/coreos/go-systemd/journal" |
| 160 | 159 |
"github.com/docker/docker/api/types/backend" |
| 161 | 160 |
"github.com/docker/docker/daemon/logger" |
| 161 |
+ "github.com/sirupsen/logrus" |
|
| 162 | 162 |
) |
| 163 | 163 |
|
| 164 | 164 |
func (s *journald) Close() error {
|
| ... | ... |
@@ -11,12 +11,12 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"sync" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/docker/daemon/logger" |
| 16 | 15 |
"github.com/docker/docker/daemon/logger/loggerutils" |
| 17 | 16 |
"github.com/docker/docker/pkg/jsonlog" |
| 18 | 17 |
"github.com/docker/go-units" |
| 19 | 18 |
"github.com/pkg/errors" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 20 |
) |
| 21 | 21 |
|
| 22 | 22 |
// Name is the name of the file that the jsonlogger logs to. |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"github.com/fsnotify/fsnotify" |
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/docker/api/types/backend" |
| 16 | 15 |
"github.com/docker/docker/daemon/logger" |
| 17 | 16 |
"github.com/docker/docker/daemon/logger/jsonfilelog/multireader" |
| ... | ... |
@@ -19,6 +18,7 @@ import ( |
| 19 | 19 |
"github.com/docker/docker/pkg/jsonlog" |
| 20 | 20 |
"github.com/docker/docker/pkg/tailfile" |
| 21 | 21 |
"github.com/pkg/errors" |
| 22 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 23 |
) |
| 23 | 24 |
|
| 24 | 25 |
const maxJSONDecodeRetry = 20000 |
| ... | ... |
@@ -18,10 +18,10 @@ import ( |
| 18 | 18 |
"sync" |
| 19 | 19 |
"time" |
| 20 | 20 |
|
| 21 |
- "github.com/Sirupsen/logrus" |
|
| 22 | 21 |
"github.com/docker/docker/daemon/logger" |
| 23 | 22 |
"github.com/docker/docker/daemon/logger/loggerutils" |
| 24 | 23 |
"github.com/docker/docker/pkg/urlutil" |
| 24 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 25 |
) |
| 26 | 26 |
|
| 27 | 27 |
const ( |
| ... | ... |
@@ -14,11 +14,11 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
syslog "github.com/RackSec/srslog" |
| 16 | 16 |
|
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/docker/docker/daemon/logger" |
| 19 | 18 |
"github.com/docker/docker/daemon/logger/loggerutils" |
| 20 | 19 |
"github.com/docker/docker/pkg/urlutil" |
| 21 | 20 |
"github.com/docker/go-connections/tlsconfig" |
| 21 |
+ "github.com/sirupsen/logrus" |
|
| 22 | 22 |
) |
| 23 | 23 |
|
| 24 | 24 |
const ( |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"golang.org/x/net/context" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/api/types/backend" |
| 13 | 12 |
containertypes "github.com/docker/docker/api/types/container" |
| 14 | 13 |
timetypes "github.com/docker/docker/api/types/time" |
| 15 | 14 |
"github.com/docker/docker/container" |
| 16 | 15 |
"github.com/docker/docker/daemon/logger" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
// ContainerLogs copies the container's log channel to the channel provided in |
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"path/filepath" |
| 5 | 5 |
"sync" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/pkg/mount" |
| 9 | 8 |
"github.com/docker/docker/pkg/plugingetter" |
| 10 | 9 |
"github.com/docker/go-metrics" |
| 11 | 10 |
"github.com/pkg/errors" |
| 12 | 11 |
"github.com/prometheus/client_golang/prometheus" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
const metricsPluginType = "MetricsCollector" |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
"os" |
| 9 | 9 |
"path/filepath" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/pkg/mount" |
| 13 | 12 |
"github.com/docker/docker/pkg/plugingetter" |
| 14 | 13 |
"github.com/docker/docker/pkg/plugins" |
| 15 | 14 |
metrics "github.com/docker/go-metrics" |
| 16 | 15 |
"github.com/pkg/errors" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
"golang.org/x/sys/unix" |
| 18 | 18 |
) |
| 19 | 19 |
|
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"strconv" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/container" |
| 13 | 12 |
"github.com/docker/docker/libcontainerd" |
| 14 | 13 |
"github.com/docker/docker/restartmanager" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
func (daemon *Daemon) setStateCounter(c *container.Container) {
|
| ... | ... |
@@ -4,11 +4,11 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/api" |
| 9 | 8 |
"github.com/docker/docker/container" |
| 10 | 9 |
"github.com/docker/docker/pkg/namesgenerator" |
| 11 | 10 |
"github.com/docker/docker/pkg/stringid" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
var ( |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"sync" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
apierrors "github.com/docker/docker/api/errors" |
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
"github.com/docker/docker/api/types/network" |
| ... | ... |
@@ -21,6 +20,7 @@ import ( |
| 21 | 21 |
"github.com/docker/libnetwork/ipamapi" |
| 22 | 22 |
networktypes "github.com/docker/libnetwork/types" |
| 23 | 23 |
"github.com/pkg/errors" |
| 24 |
+ "github.com/sirupsen/logrus" |
|
| 24 | 25 |
"golang.org/x/net/context" |
| 25 | 26 |
) |
| 26 | 27 |
|
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"strings" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
containertypes "github.com/docker/docker/api/types/container" |
| 16 | 15 |
"github.com/docker/docker/container" |
| 17 | 16 |
"github.com/docker/docker/daemon/caps" |
| ... | ... |
@@ -27,6 +26,7 @@ import ( |
| 27 | 27 |
"github.com/opencontainers/runc/libcontainer/devices" |
| 28 | 28 |
"github.com/opencontainers/runc/libcontainer/user" |
| 29 | 29 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 30 |
+ "github.com/sirupsen/logrus" |
|
| 30 | 31 |
) |
| 31 | 32 |
|
| 32 | 33 |
var ( |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"sync/atomic" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/distribution/reference" |
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/api/types/filters" |
| ... | ... |
@@ -20,6 +19,7 @@ import ( |
| 20 | 20 |
"github.com/docker/docker/volume" |
| 21 | 21 |
"github.com/docker/libnetwork" |
| 22 | 22 |
digest "github.com/opencontainers/go-digest" |
| 23 |
+ "github.com/sirupsen/logrus" |
|
| 23 | 24 |
"golang.org/x/net/context" |
| 24 | 25 |
) |
| 25 | 26 |
|
| ... | ... |
@@ -4,10 +4,10 @@ import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"fmt" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/daemon/config" |
| 9 | 8 |
"github.com/docker/docker/daemon/discovery" |
| 10 | 9 |
"github.com/docker/docker/libcontainerd" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// Reload reads configuration changes and modifies the |
| ... | ... |
@@ -5,9 +5,9 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
dockercontainer "github.com/docker/docker/container" |
| 10 | 9 |
"github.com/docker/libnetwork" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// ContainerRename changes the name of a container, using the oldName |
| ... | ... |
@@ -5,10 +5,10 @@ package daemon |
| 5 | 5 |
import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/container" |
| 10 | 9 |
"github.com/docker/docker/profiles/seccomp" |
| 11 | 10 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
var supportsSeccomp = true |
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"google.golang.org/grpc" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
apierrors "github.com/docker/docker/api/errors" |
| 15 | 14 |
"github.com/docker/docker/api/types" |
| 16 | 15 |
containertypes "github.com/docker/docker/api/types/container" |
| 17 | 16 |
"github.com/docker/docker/container" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
// ContainerStart starts a container. |
| ... | ... |
@@ -5,10 +5,10 @@ package stats |
| 5 | 5 |
import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/api/types" |
| 10 | 9 |
"github.com/docker/docker/container" |
| 11 | 10 |
"github.com/docker/docker/pkg/pubsub" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// Collect registers the container with the collector and adds it to |
| ... | ... |
@@ -6,9 +6,9 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/api/errors" |
| 11 | 10 |
containerpkg "github.com/docker/docker/container" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// ContainerStop looks for the given container and terminates it, |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
dockererrors "github.com/docker/docker/api/errors" |
| 14 | 13 |
"github.com/docker/docker/api/types" |
| 15 | 14 |
containertypes "github.com/docker/docker/api/types/container" |
| ... | ... |
@@ -17,6 +16,7 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/container" |
| 18 | 18 |
"github.com/docker/docker/volume" |
| 19 | 19 |
"github.com/docker/docker/volume/drivers" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 21 |
) |
| 21 | 22 |
|
| 22 | 23 |
var ( |
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"strings" |
| 6 | 6 |
"syscall" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/distribution" |
| 10 | 9 |
"github.com/docker/distribution/reference" |
| 11 | 10 |
"github.com/docker/distribution/registry/api/errcode" |
| ... | ... |
@@ -14,6 +13,7 @@ import ( |
| 14 | 14 |
"github.com/docker/distribution/registry/client/auth" |
| 15 | 15 |
"github.com/docker/docker/distribution/xfer" |
| 16 | 16 |
"github.com/pkg/errors" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 18 |
) |
| 18 | 19 |
|
| 19 | 20 |
// ErrNoSupport is an error type used for errors indicating that an operation |
| ... | ... |
@@ -3,7 +3,6 @@ package distribution |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/distribution/reference" |
| 8 | 7 |
"github.com/docker/docker/api" |
| 9 | 8 |
"github.com/docker/docker/distribution/metadata" |
| ... | ... |
@@ -11,6 +10,7 @@ import ( |
| 11 | 11 |
refstore "github.com/docker/docker/reference" |
| 12 | 12 |
"github.com/docker/docker/registry" |
| 13 | 13 |
"github.com/opencontainers/go-digest" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 15 |
"golang.org/x/net/context" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"strings" |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/distribution/reference" |
| 16 | 15 |
"github.com/docker/distribution/registry/client/transport" |
| 17 | 16 |
"github.com/docker/docker/distribution/metadata" |
| ... | ... |
@@ -24,6 +23,7 @@ import ( |
| 24 | 24 |
"github.com/docker/docker/pkg/progress" |
| 25 | 25 |
"github.com/docker/docker/pkg/stringid" |
| 26 | 26 |
"github.com/docker/docker/registry" |
| 27 |
+ "github.com/sirupsen/logrus" |
|
| 27 | 28 |
"golang.org/x/net/context" |
| 28 | 29 |
) |
| 29 | 30 |
|
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"os" |
| 11 | 11 |
"runtime" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/distribution" |
| 15 | 14 |
"github.com/docker/distribution/manifest/manifestlist" |
| 16 | 15 |
"github.com/docker/distribution/manifest/schema1" |
| ... | ... |
@@ -31,6 +30,7 @@ import ( |
| 31 | 31 |
refstore "github.com/docker/docker/reference" |
| 32 | 32 |
"github.com/docker/docker/registry" |
| 33 | 33 |
"github.com/opencontainers/go-digest" |
| 34 |
+ "github.com/sirupsen/logrus" |
|
| 34 | 35 |
"golang.org/x/net/context" |
| 35 | 36 |
) |
| 36 | 37 |
|
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"os" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/distribution" |
| 11 | 10 |
"github.com/docker/distribution/context" |
| 12 | 11 |
"github.com/docker/distribution/manifest/schema2" |
| 13 | 12 |
"github.com/docker/distribution/registry/client/transport" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
var _ distribution.Describable = &v2LayerDescriptor{}
|
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
"io" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/distribution/reference" |
| 11 | 10 |
"github.com/docker/docker/distribution/metadata" |
| 12 | 11 |
"github.com/docker/docker/pkg/progress" |
| 13 | 12 |
"github.com/docker/docker/registry" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
"golang.org/x/net/context" |
| 15 | 15 |
) |
| 16 | 16 |
|
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"sync" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/distribution/reference" |
| 9 | 8 |
"github.com/docker/distribution/registry/client/transport" |
| 10 | 9 |
"github.com/docker/docker/distribution/metadata" |
| ... | ... |
@@ -17,6 +16,7 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/pkg/stringid" |
| 18 | 18 |
"github.com/docker/docker/registry" |
| 19 | 19 |
"github.com/opencontainers/go-digest" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 21 |
"golang.org/x/net/context" |
| 21 | 22 |
) |
| 22 | 23 |
|
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/distribution" |
| 16 | 15 |
"github.com/docker/distribution/manifest/schema1" |
| 17 | 16 |
"github.com/docker/distribution/manifest/schema2" |
| ... | ... |
@@ -26,6 +25,7 @@ import ( |
| 26 | 26 |
"github.com/docker/docker/pkg/stringid" |
| 27 | 27 |
"github.com/docker/docker/registry" |
| 28 | 28 |
"github.com/opencontainers/go-digest" |
| 29 |
+ "github.com/sirupsen/logrus" |
|
| 29 | 30 |
) |
| 30 | 31 |
|
| 31 | 32 |
const ( |
| ... | ... |
@@ -11,13 +11,13 @@ import ( |
| 11 | 11 |
"strings" |
| 12 | 12 |
"testing" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/distribution/reference" |
| 16 | 15 |
"github.com/docker/docker/api/types" |
| 17 | 16 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 18 | 17 |
"github.com/docker/docker/pkg/archive" |
| 19 | 18 |
"github.com/docker/docker/pkg/stringid" |
| 20 | 19 |
"github.com/docker/docker/registry" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 21 |
"golang.org/x/net/context" |
| 22 | 22 |
) |
| 23 | 23 |
|
| ... | ... |
@@ -6,9 +6,9 @@ import ( |
| 6 | 6 |
"os" |
| 7 | 7 |
"syscall" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/pkg/progress" |
| 11 | 10 |
"github.com/docker/docker/pkg/streamformatter" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// WriteDistributionProgress is a helper for writing progress from chan to JSON |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
"runtime" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/distribution" |
| 12 | 11 |
"github.com/docker/docker/image" |
| 13 | 12 |
"github.com/docker/docker/layer" |
| 14 | 13 |
"github.com/docker/docker/pkg/archive" |
| 15 | 14 |
"github.com/docker/docker/pkg/ioutils" |
| 16 | 15 |
"github.com/docker/docker/pkg/progress" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
"golang.org/x/net/context" |
| 18 | 18 |
) |
| 19 | 19 |
|
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/docker/api/types" |
| 15 | 14 |
"github.com/docker/docker/api/types/filters" |
| 16 | 15 |
"github.com/docker/docker/client" |
| 17 | 16 |
"github.com/docker/docker/pkg/stdcopy" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
const ( |
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
"path/filepath" |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/pkg/ioutils" |
| 12 | 11 |
"github.com/opencontainers/go-digest" |
| 13 | 12 |
"github.com/pkg/errors" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// DigestWalkFunc is function called by StoreBackend.Walk |
| ... | ... |
@@ -7,12 +7,12 @@ import ( |
| 7 | 7 |
"sync" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/distribution/digestset" |
| 12 | 11 |
"github.com/docker/docker/layer" |
| 13 | 12 |
"github.com/docker/docker/pkg/system" |
| 14 | 13 |
"github.com/opencontainers/go-digest" |
| 15 | 14 |
"github.com/pkg/errors" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
// Store is an interface for creating and accessing images |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"reflect" |
| 12 | 12 |
"runtime" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/distribution" |
| 16 | 15 |
"github.com/docker/distribution/reference" |
| 17 | 16 |
"github.com/docker/docker/image" |
| ... | ... |
@@ -25,6 +24,7 @@ import ( |
| 25 | 25 |
"github.com/docker/docker/pkg/symlink" |
| 26 | 26 |
"github.com/docker/docker/pkg/system" |
| 27 | 27 |
"github.com/opencontainers/go-digest" |
| 28 |
+ "github.com/sirupsen/logrus" |
|
| 28 | 29 |
) |
| 29 | 30 |
|
| 30 | 31 |
func (l *tarexporter) Load(inTar io.ReadCloser, outStream io.Writer, quiet bool) error {
|
| ... | ... |
@@ -5,12 +5,12 @@ import ( |
| 5 | 5 |
"reflect" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/api/types/versions" |
| 10 | 9 |
"github.com/docker/docker/image" |
| 11 | 10 |
"github.com/docker/docker/layer" |
| 12 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 13 | 12 |
"github.com/opencontainers/go-digest" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// noFallbackMinVersion is the minimum version for which v1compatibility |
| ... | ... |
@@ -9,10 +9,10 @@ import ( |
| 9 | 9 |
"strconv" |
| 10 | 10 |
"strings" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
eventstestutils "github.com/docker/docker/daemon/events/testutils" |
| 14 | 13 |
"github.com/docker/docker/integration-cli/checker" |
| 15 | 14 |
"github.com/go-check/check" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
// eventMatcher is a function that tries to match an event input. |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"sync" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/distribution" |
| 13 | 12 |
"github.com/docker/docker/daemon/graphdriver" |
| 14 | 13 |
"github.com/docker/docker/pkg/idtools" |
| ... | ... |
@@ -16,6 +15,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/pkg/stringid" |
| 17 | 17 |
"github.com/docker/docker/pkg/system" |
| 18 | 18 |
"github.com/opencontainers/go-digest" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 20 |
"github.com/vbatts/tar-split/tar/asm" |
| 20 | 21 |
"github.com/vbatts/tar-split/tar/storage" |
| 21 | 22 |
) |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"sync" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
containerd "github.com/containerd/containerd/api/grpc/types" |
| 12 | 11 |
containerd_runtime_types "github.com/containerd/containerd/runtime" |
| 13 | 12 |
"github.com/docker/docker/pkg/ioutils" |
| ... | ... |
@@ -15,6 +14,7 @@ import ( |
| 15 | 15 |
"github.com/golang/protobuf/ptypes" |
| 16 | 16 |
"github.com/golang/protobuf/ptypes/timestamp" |
| 17 | 17 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 19 |
"golang.org/x/net/context" |
| 19 | 20 |
"golang.org/x/sys/unix" |
| 20 | 21 |
) |
| ... | ... |
@@ -10,10 +10,10 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"sync" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
containerd "github.com/containerd/containerd/api/grpc/types" |
| 15 | 14 |
"github.com/docker/docker/pkg/idtools" |
| 16 | 15 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
"golang.org/x/net/context" |
| 18 | 18 |
) |
| 19 | 19 |
|
| ... | ... |
@@ -15,9 +15,9 @@ import ( |
| 15 | 15 |
"golang.org/x/net/context" |
| 16 | 16 |
|
| 17 | 17 |
"github.com/Microsoft/hcsshim" |
| 18 |
- "github.com/Sirupsen/logrus" |
|
| 19 | 18 |
"github.com/docker/docker/pkg/sysinfo" |
| 20 | 19 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 21 |
) |
| 22 | 22 |
|
| 23 | 23 |
type client struct {
|
| ... | ... |
@@ -11,10 +11,10 @@ import ( |
| 11 | 11 |
"sync" |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
containerd "github.com/containerd/containerd/api/grpc/types" |
| 16 | 15 |
"github.com/docker/docker/pkg/ioutils" |
| 17 | 16 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 18 |
"github.com/tonistiigi/fifo" |
| 19 | 19 |
"golang.org/x/net/context" |
| 20 | 20 |
"golang.org/x/sys/unix" |
| ... | ... |
@@ -9,9 +9,9 @@ import ( |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Microsoft/hcsshim" |
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/docker/pkg/system" |
| 14 | 13 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
"golang.org/x/sys/windows" |
| 16 | 16 |
) |
| 17 | 17 |
|
| ... | ... |
@@ -17,12 +17,12 @@ import ( |
| 17 | 17 |
"sync" |
| 18 | 18 |
"time" |
| 19 | 19 |
|
| 20 |
- "github.com/Sirupsen/logrus" |
|
| 21 | 20 |
containerd "github.com/containerd/containerd/api/grpc/types" |
| 22 | 21 |
"github.com/docker/docker/pkg/locker" |
| 23 | 22 |
"github.com/docker/docker/pkg/system" |
| 24 | 23 |
"github.com/golang/protobuf/ptypes" |
| 25 | 24 |
"github.com/golang/protobuf/ptypes/timestamp" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 26 | 26 |
"golang.org/x/net/context" |
| 27 | 27 |
"golang.org/x/sys/unix" |
| 28 | 28 |
"google.golang.org/grpc" |
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
|
| 14 | 14 |
"encoding/json" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/docker/distribution/reference" |
| 18 | 17 |
"github.com/docker/docker/distribution/metadata" |
| 19 | 18 |
"github.com/docker/docker/image" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/pkg/ioutils" |
| 23 | 23 |
refstore "github.com/docker/docker/reference" |
| 24 | 24 |
"github.com/opencontainers/go-digest" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
) |
| 26 | 27 |
|
| 27 | 28 |
type graphIDRegistrar interface {
|
| ... | ... |
@@ -16,13 +16,13 @@ import ( |
| 16 | 16 |
"strings" |
| 17 | 17 |
"syscall" |
| 18 | 18 |
|
| 19 |
- "github.com/Sirupsen/logrus" |
|
| 20 | 19 |
"github.com/docker/docker/pkg/fileutils" |
| 21 | 20 |
"github.com/docker/docker/pkg/idtools" |
| 22 | 21 |
"github.com/docker/docker/pkg/ioutils" |
| 23 | 22 |
"github.com/docker/docker/pkg/pools" |
| 24 | 23 |
"github.com/docker/docker/pkg/promise" |
| 25 | 24 |
"github.com/docker/docker/pkg/system" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 26 | 26 |
) |
| 27 | 27 |
|
| 28 | 28 |
type ( |
| ... | ... |
@@ -13,10 +13,10 @@ import ( |
| 13 | 13 |
"syscall" |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/docker/docker/pkg/idtools" |
| 18 | 17 |
"github.com/docker/docker/pkg/pools" |
| 19 | 18 |
"github.com/docker/docker/pkg/system" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 20 |
) |
| 21 | 21 |
|
| 22 | 22 |
// ChangeType represents the change type. |
| ... | ... |
@@ -10,10 +10,10 @@ import ( |
| 10 | 10 |
"runtime" |
| 11 | 11 |
"strings" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/docker/pkg/idtools" |
| 15 | 14 |
"github.com/docker/docker/pkg/pools" |
| 16 | 15 |
"github.com/docker/docker/pkg/system" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
// UnpackLayer unpack `layer` to a `dest`. The stream `layer` can be |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/docker/pkg/discovery" |
| 11 | 10 |
"github.com/docker/go-connections/tlsconfig" |
| 12 | 11 |
"github.com/docker/libkv" |
| ... | ... |
@@ -14,6 +13,7 @@ import ( |
| 14 | 14 |
"github.com/docker/libkv/store/consul" |
| 15 | 15 |
"github.com/docker/libkv/store/etcd" |
| 16 | 16 |
"github.com/docker/libkv/store/zookeeper" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 18 |
) |
| 18 | 19 |
|
| 19 | 20 |
const ( |
| ... | ... |
@@ -9,10 +9,10 @@ import ( |
| 9 | 9 |
"net/url" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/docker/pkg/plugins/transport" |
| 14 | 13 |
"github.com/docker/go-connections/sockets" |
| 15 | 14 |
"github.com/docker/go-connections/tlsconfig" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
const ( |
| ... | ... |
@@ -15,7 +15,6 @@ import ( |
| 15 | 15 |
"path/filepath" |
| 16 | 16 |
"strings" |
| 17 | 17 |
|
| 18 |
- "github.com/Sirupsen/logrus" |
|
| 19 | 18 |
"github.com/docker/distribution/manifest/schema2" |
| 20 | 19 |
"github.com/docker/distribution/reference" |
| 21 | 20 |
"github.com/docker/docker/api/types" |
| ... | ... |
@@ -36,6 +35,7 @@ import ( |
| 36 | 36 |
refstore "github.com/docker/docker/reference" |
| 37 | 37 |
"github.com/opencontainers/go-digest" |
| 38 | 38 |
"github.com/pkg/errors" |
| 39 |
+ "github.com/sirupsen/logrus" |
|
| 39 | 40 |
"golang.org/x/net/context" |
| 40 | 41 |
) |
| 41 | 42 |
|
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"os" |
| 8 | 8 |
"path/filepath" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/docker/distribution/xfer" |
| 12 | 11 |
"github.com/docker/docker/image" |
| 13 | 12 |
"github.com/docker/docker/layer" |
| ... | ... |
@@ -16,6 +15,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/pkg/progress" |
| 17 | 17 |
"github.com/opencontainers/go-digest" |
| 18 | 18 |
"github.com/pkg/errors" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 20 |
"golang.org/x/net/context" |
| 20 | 21 |
) |
| 21 | 22 |
|
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
"strings" |
| 14 | 14 |
"sync" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/docker/distribution/reference" |
| 18 | 17 |
"github.com/docker/docker/api/types" |
| 19 | 18 |
"github.com/docker/docker/image" |
| ... | ... |
@@ -28,6 +27,7 @@ import ( |
| 28 | 28 |
"github.com/docker/docker/registry" |
| 29 | 29 |
"github.com/opencontainers/go-digest" |
| 30 | 30 |
"github.com/pkg/errors" |
| 31 |
+ "github.com/sirupsen/logrus" |
|
| 31 | 32 |
) |
| 32 | 33 |
|
| 33 | 34 |
const configFileName = "config.json" |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"path/filepath" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/docker/api/types" |
| 15 | 14 |
"github.com/docker/docker/daemon/initlayer" |
| 16 | 15 |
"github.com/docker/docker/libcontainerd" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
"github.com/opencontainers/go-digest" |
| 23 | 23 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 24 | 24 |
"github.com/pkg/errors" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
"golang.org/x/sys/unix" |
| 26 | 27 |
) |
| 27 | 28 |
|
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/distribution/reference" |
| 9 | 8 |
"github.com/docker/docker/pkg/plugingetter" |
| 10 | 9 |
"github.com/docker/docker/pkg/plugins" |
| 11 | 10 |
"github.com/docker/docker/plugin/v2" |
| 12 | 11 |
"github.com/pkg/errors" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
/* allowV1PluginsFallback determines daemon's support for V1 plugins. |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/distribution/registry/client/auth" |
| 13 | 12 |
"github.com/docker/distribution/registry/client/auth/challenge" |
| 14 | 13 |
"github.com/docker/distribution/registry/client/transport" |
| 15 | 14 |
"github.com/docker/docker/api/types" |
| 16 | 15 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
const ( |
| ... | ... |
@@ -8,11 +8,11 @@ import ( |
| 8 | 8 |
"strconv" |
| 9 | 9 |
"strings" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/distribution/reference" |
| 13 | 12 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 14 | 13 |
"github.com/docker/docker/opts" |
| 15 | 14 |
"github.com/pkg/errors" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
"github.com/spf13/pflag" |
| 17 | 17 |
) |
| 18 | 18 |
|
| ... | ... |
@@ -9,9 +9,9 @@ import ( |
| 9 | 9 |
"net/url" |
| 10 | 10 |
"strings" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/distribution/registry/client/transport" |
| 14 | 13 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
// V1Endpoint stores basic information about a V1 registry endpoint. |
| ... | ... |
@@ -13,10 +13,10 @@ import ( |
| 13 | 13 |
"strings" |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/docker/distribution/registry/client/transport" |
| 18 | 17 |
"github.com/docker/go-connections/sockets" |
| 19 | 18 |
"github.com/docker/go-connections/tlsconfig" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 20 |
) |
| 21 | 21 |
|
| 22 | 22 |
var ( |
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"golang.org/x/net/context" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/distribution/reference" |
| 15 | 14 |
"github.com/docker/distribution/registry/client/auth" |
| 16 | 15 |
"github.com/docker/docker/api/types" |
| 17 | 16 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
const ( |
| ... | ... |
@@ -18,7 +18,6 @@ import ( |
| 18 | 18 |
"strconv" |
| 19 | 19 |
"strings" |
| 20 | 20 |
|
| 21 |
- "github.com/Sirupsen/logrus" |
|
| 22 | 21 |
"github.com/docker/distribution/reference" |
| 23 | 22 |
"github.com/docker/distribution/registry/api/errcode" |
| 24 | 23 |
"github.com/docker/docker/api/types" |
| ... | ... |
@@ -28,6 +27,7 @@ import ( |
| 28 | 28 |
"github.com/docker/docker/pkg/stringid" |
| 29 | 29 |
"github.com/docker/docker/pkg/tarsum" |
| 30 | 30 |
"github.com/docker/docker/registry/resumable" |
| 31 |
+ "github.com/sirupsen/logrus" |
|
| 31 | 32 |
) |
| 32 | 33 |
|
| 33 | 34 |
var ( |
| ... | ... |
@@ -1,17 +1,17 @@ |
| 1 | 1 |
# the following lines are in sorted order, FYI |
| 2 |
-github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62 |
|
| 3 |
-github.com/Microsoft/hcsshim v0.5.25 |
|
| 2 |
+github.com/Azure/go-ansiterm 19f72df4d05d31cbe1c56bfc8045c96babff6c7e |
|
| 3 |
+github.com/Microsoft/hcsshim v0.6.1 |
|
| 4 | 4 |
github.com/Microsoft/go-winio v0.4.2 |
| 5 |
-github.com/Sirupsen/logrus v0.11.0 |
|
| 6 |
-github.com/moby/buildkit fed5c1d9cee6f734f58f3addca6e8d1750df48a6 |
|
| 5 |
+github.com/moby/buildkit da2b9dc7dab99e824b2b1067ad7d0523e32dd2d9 https://github.com/dmcgowan/buildkit.git |
|
| 7 | 6 |
github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 |
| 8 | 7 |
github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a |
| 9 | 8 |
github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git |
| 10 | 9 |
github.com/gorilla/context v1.1 |
| 11 | 10 |
github.com/gorilla/mux v1.1 |
| 12 |
-github.com/jhowardmsft/opengcs v0.0.9 |
|
| 11 |
+github.com/jhowardmsft/opengcs b9d0120d36f26e981a50bf18bac1bb3f0c2b8fef https://github.com/dmcgowan/opengcs.git |
|
| 13 | 12 |
github.com/kr/pty 5cf931ef8f |
| 14 | 13 |
github.com/mattn/go-shellwords v1.0.3 |
| 14 |
+github.com/sirupsen/logrus v1.0.1 |
|
| 15 | 15 |
github.com/tchap/go-patricia v2.2.6 |
| 16 | 16 |
github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 |
| 17 | 17 |
golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 |
| ... | ... |
@@ -27,8 +27,8 @@ github.com/imdario/mergo 0.2.1 |
| 27 | 27 |
golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0 |
| 28 | 28 |
|
| 29 | 29 |
#get libnetwork packages |
| 30 |
-github.com/docker/libnetwork e23c06b2917c82f6eed18c368f515060af78a09f |
|
| 31 |
-github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894 |
|
| 30 |
+github.com/docker/libnetwork 248fd5ea6a67f8810da322e6e7441e8de96a9045 https://github.com/dmcgowan/libnetwork.git |
|
| 31 |
+github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 |
|
| 32 | 32 |
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 |
| 33 | 33 |
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec |
| 34 | 34 |
github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b |
| ... | ... |
@@ -51,7 +51,7 @@ github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904 |
| 51 | 51 |
github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7 |
| 52 | 52 |
|
| 53 | 53 |
# get graph and distribution packages |
| 54 |
-github.com/docker/distribution b38e5838b7b2f2ad48e06ec4b500011976080621 |
|
| 54 |
+github.com/docker/distribution edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c |
|
| 55 | 55 |
github.com/vbatts/tar-split v0.10.1 |
| 56 | 56 |
github.com/opencontainers/go-digest a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb |
| 57 | 57 |
|
| ... | ... |
@@ -62,7 +62,7 @@ github.com/pborman/uuid v1.0 |
| 62 | 62 |
google.golang.org/grpc v1.3.0 |
| 63 | 63 |
|
| 64 | 64 |
# When updating, also update RUNC_COMMIT in hack/dockerfile/binaries-commits accordingly |
| 65 |
-github.com/opencontainers/runc 2d41c047c83e09a6d61d464906feb2a2f3c52aa4 https://github.com/docker/runc |
|
| 65 |
+github.com/opencontainers/runc e9325d442f5979c4f79bfa9e09bdf7abb74ba03b https://github.com/dmcgowan/runc.git |
|
| 66 | 66 |
github.com/opencontainers/image-spec 372ad780f63454fbbbbcc7cf80e5b90245c13e13 |
| 67 | 67 |
github.com/opencontainers/runtime-spec d42f1eb741e6361e858d83fc75aa6893b66292c4 # specs |
| 68 | 68 |
|
| ... | ... |
@@ -101,13 +101,13 @@ github.com/googleapis/gax-go da06d194a00e19ce00d9011a13931c3f6f6887c7 |
| 101 | 101 |
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 |
| 102 | 102 |
|
| 103 | 103 |
# containerd |
| 104 |
-github.com/containerd/containerd 3addd840653146c90a254301d6c3a663c7fd6429 |
|
| 104 |
+github.com/containerd/containerd fc10004571bb9b26695ccbf2dd4a83213f60b93e https://github.com/dmcgowan/containerd.git |
|
| 105 | 105 |
github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4 |
| 106 | 106 |
github.com/stevvooe/continuity cd7a8e21e2b6f84799f5dd4b65faf49c8d3ee02d |
| 107 | 107 |
github.com/tonistiigi/fsutil 0ac4c11b053b9c5c7c47558f81f96c7100ce50fb |
| 108 | 108 |
|
| 109 | 109 |
# cluster |
| 110 |
-github.com/docker/swarmkit 3e2dd3c0a76149b1620b42d28dd6ff48270404e5 |
|
| 110 |
+github.com/docker/swarmkit 8bdecc57887ffc598b63d6433f58e0d2852112c3 https://github.com/dmcgowan/swarmkit.git |
|
| 111 | 111 |
github.com/gogo/protobuf v0.4 |
| 112 | 112 |
github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a |
| 113 | 113 |
github.com/google/certificate-transparency d90e65c3a07988180c5b1ece71791c0b6506826e |
| ... | ... |
@@ -7,3 +7,6 @@ For example the parser might receive "ESC, [, A" as a stream of three characters |
| 7 | 7 |
The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go). |
| 8 | 8 |
|
| 9 | 9 |
See parser_test.go for examples exercising the state machine and generating appropriate function calls. |
| 10 |
+ |
|
| 11 |
+----- |
|
| 12 |
+This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
package hcsshim |
| 2 | 2 |
|
| 3 |
-import "github.com/Sirupsen/logrus" |
|
| 3 |
+import "github.com/sirupsen/logrus" |
|
| 4 | 4 |
|
| 5 | 5 |
// ActivateLayer will find the layer with the given id and mount it's filesystem. |
| 6 | 6 |
// For a read/write layer, the mounted filesystem will appear as a volume on the |
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
"syscall" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
var ( |
| ... | ... |
@@ -16,9 +16,10 @@ var ( |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
const ( |
| 19 |
- pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}`
|
|
| 20 |
- statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}`
|
|
| 21 |
- processListQuery = `{ "PropertyTypes" : ["ProcessList"]}`
|
|
| 19 |
+ pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}`
|
|
| 20 |
+ statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}`
|
|
| 21 |
+ processListQuery = `{ "PropertyTypes" : ["ProcessList"]}`
|
|
| 22 |
+ mappedVirtualDiskQuery = `{ "PropertyTypes" : ["MappedVirtualDisk"]}`
|
|
| 22 | 23 |
) |
| 23 | 24 |
|
| 24 | 25 |
type container struct {
|
| ... | ... |
@@ -30,20 +31,21 @@ type container struct {
|
| 30 | 30 |
|
| 31 | 31 |
// ContainerProperties holds the properties for a container and the processes running in that container |
| 32 | 32 |
type ContainerProperties struct {
|
| 33 |
- ID string `json:"Id"` |
|
| 34 |
- Name string |
|
| 35 |
- SystemType string |
|
| 36 |
- Owner string |
|
| 37 |
- SiloGUID string `json:"SiloGuid,omitempty"` |
|
| 38 |
- RuntimeID string `json:"RuntimeId,omitempty"` |
|
| 39 |
- IsRuntimeTemplate bool `json:",omitempty"` |
|
| 40 |
- RuntimeImagePath string `json:",omitempty"` |
|
| 41 |
- Stopped bool `json:",omitempty"` |
|
| 42 |
- ExitType string `json:",omitempty"` |
|
| 43 |
- AreUpdatesPending bool `json:",omitempty"` |
|
| 44 |
- ObRoot string `json:",omitempty"` |
|
| 45 |
- Statistics Statistics `json:",omitempty"` |
|
| 46 |
- ProcessList []ProcessListItem `json:",omitempty"` |
|
| 33 |
+ ID string `json:"Id"` |
|
| 34 |
+ Name string |
|
| 35 |
+ SystemType string |
|
| 36 |
+ Owner string |
|
| 37 |
+ SiloGUID string `json:"SiloGuid,omitempty"` |
|
| 38 |
+ RuntimeID string `json:"RuntimeId,omitempty"` |
|
| 39 |
+ IsRuntimeTemplate bool `json:",omitempty"` |
|
| 40 |
+ RuntimeImagePath string `json:",omitempty"` |
|
| 41 |
+ Stopped bool `json:",omitempty"` |
|
| 42 |
+ ExitType string `json:",omitempty"` |
|
| 43 |
+ AreUpdatesPending bool `json:",omitempty"` |
|
| 44 |
+ ObRoot string `json:",omitempty"` |
|
| 45 |
+ Statistics Statistics `json:",omitempty"` |
|
| 46 |
+ ProcessList []ProcessListItem `json:",omitempty"` |
|
| 47 |
+ MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"` |
|
| 47 | 48 |
} |
| 48 | 49 |
|
| 49 | 50 |
// MemoryStats holds the memory statistics for a container |
| ... | ... |
@@ -103,6 +105,11 @@ type ProcessListItem struct {
|
| 103 | 103 |
UserTime100ns uint64 `json:",omitempty"` |
| 104 | 104 |
} |
| 105 | 105 |
|
| 106 |
+// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container |
|
| 107 |
+type MappedVirtualDiskController struct {
|
|
| 108 |
+ MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"` |
|
| 109 |
+} |
|
| 110 |
+ |
|
| 106 | 111 |
// Type of Request Support in ModifySystem |
| 107 | 112 |
type RequestType string |
| 108 | 113 |
|
| ... | ... |
@@ -487,6 +494,55 @@ func (container *container) ProcessList() ([]ProcessListItem, error) {
|
| 487 | 487 |
return properties.ProcessList, nil |
| 488 | 488 |
} |
| 489 | 489 |
|
| 490 |
+// MappedVirtualDisks returns a map of the controllers and the disks mapped |
|
| 491 |
+// to a container. |
|
| 492 |
+// |
|
| 493 |
+// Example of JSON returned by the query. |
|
| 494 |
+//{
|
|
| 495 |
+// "Id":"1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3_svm", |
|
| 496 |
+// "SystemType":"Container", |
|
| 497 |
+// "RuntimeOsType":"Linux", |
|
| 498 |
+// "RuntimeId":"00000000-0000-0000-0000-000000000000", |
|
| 499 |
+// "State":"Running", |
|
| 500 |
+// "MappedVirtualDiskControllers":{
|
|
| 501 |
+// "0":{
|
|
| 502 |
+// "MappedVirtualDisks":{
|
|
| 503 |
+// "2":{
|
|
| 504 |
+// "HostPath":"C:\\lcow\\lcow\\scratch\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3.vhdx", |
|
| 505 |
+// "ContainerPath":"/mnt/gcs/LinuxServiceVM/scratch", |
|
| 506 |
+// "Lun":2, |
|
| 507 |
+// "CreateInUtilityVM":true |
|
| 508 |
+// }, |
|
| 509 |
+// "3":{
|
|
| 510 |
+// "HostPath":"C:\\lcow\\lcow\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3\\sandbox.vhdx", |
|
| 511 |
+// "Lun":3, |
|
| 512 |
+// "CreateInUtilityVM":true, |
|
| 513 |
+// "AttachOnly":true |
|
| 514 |
+// } |
|
| 515 |
+// } |
|
| 516 |
+// } |
|
| 517 |
+// } |
|
| 518 |
+//} |
|
| 519 |
+func (container *container) MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) {
|
|
| 520 |
+ container.handleLock.RLock() |
|
| 521 |
+ defer container.handleLock.RUnlock() |
|
| 522 |
+ operation := "MappedVirtualDiskList" |
|
| 523 |
+ title := "HCSShim::Container::" + operation |
|
| 524 |
+ logrus.Debugf(title+" id=%s", container.id) |
|
| 525 |
+ |
|
| 526 |
+ if container.handle == 0 {
|
|
| 527 |
+ return nil, makeContainerError(container, operation, "", ErrAlreadyClosed) |
|
| 528 |
+ } |
|
| 529 |
+ |
|
| 530 |
+ properties, err := container.properties(mappedVirtualDiskQuery) |
|
| 531 |
+ if err != nil {
|
|
| 532 |
+ return nil, makeContainerError(container, operation, "", err) |
|
| 533 |
+ } |
|
| 534 |
+ |
|
| 535 |
+ logrus.Debugf(title+" succeeded id=%s", container.id) |
|
| 536 |
+ return properties.MappedVirtualDiskControllers, nil |
|
| 537 |
+} |
|
| 538 |
+ |
|
| 490 | 539 |
// Pause pauses the execution of the container. This feature is not enabled in TP5. |
| 491 | 540 |
func (container *container) Pause() error {
|
| 492 | 541 |
container.handleLock.RLock() |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
package hcsshim |
| 2 | 2 |
|
| 3 |
-import "github.com/Sirupsen/logrus" |
|
| 3 |
+import "github.com/sirupsen/logrus" |
|
| 4 | 4 |
|
| 5 | 5 |
// CreateSandboxLayer creates and populates new read-write layer for use by a container. |
| 6 | 6 |
// This requires both the id of the direct parent layer, as well as the full list |
| 15 | 15 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,183 @@ |
| 0 |
+package hcsshim |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "encoding/json" |
|
| 4 |
+ "fmt" |
|
| 5 |
+ "net" |
|
| 6 |
+ |
|
| 7 |
+ "github.com/sirupsen/logrus" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+// HNSEndpoint represents a network endpoint in HNS |
|
| 11 |
+type HNSEndpoint struct {
|
|
| 12 |
+ Id string `json:"ID,omitempty"` |
|
| 13 |
+ Name string `json:",omitempty"` |
|
| 14 |
+ VirtualNetwork string `json:",omitempty"` |
|
| 15 |
+ VirtualNetworkName string `json:",omitempty"` |
|
| 16 |
+ Policies []json.RawMessage `json:",omitempty"` |
|
| 17 |
+ MacAddress string `json:",omitempty"` |
|
| 18 |
+ IPAddress net.IP `json:",omitempty"` |
|
| 19 |
+ DNSSuffix string `json:",omitempty"` |
|
| 20 |
+ DNSServerList string `json:",omitempty"` |
|
| 21 |
+ GatewayAddress string `json:",omitempty"` |
|
| 22 |
+ EnableInternalDNS bool `json:",omitempty"` |
|
| 23 |
+ DisableICC bool `json:",omitempty"` |
|
| 24 |
+ PrefixLength uint8 `json:",omitempty"` |
|
| 25 |
+ IsRemoteEndpoint bool `json:",omitempty"` |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+// HNSEndpointRequest makes a HNS call to modify/query a network endpoint |
|
| 29 |
+func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
|
|
| 30 |
+ endpoint := &HNSEndpoint{}
|
|
| 31 |
+ err := hnsCall(method, "/endpoints/"+path, request, &endpoint) |
|
| 32 |
+ if err != nil {
|
|
| 33 |
+ return nil, err |
|
| 34 |
+ } |
|
| 35 |
+ |
|
| 36 |
+ return endpoint, nil |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+// HNSListEndpointRequest makes a HNS call to query the list of available endpoints |
|
| 40 |
+func HNSListEndpointRequest() ([]HNSEndpoint, error) {
|
|
| 41 |
+ var endpoint []HNSEndpoint |
|
| 42 |
+ err := hnsCall("GET", "/endpoints/", "", &endpoint)
|
|
| 43 |
+ if err != nil {
|
|
| 44 |
+ return nil, err |
|
| 45 |
+ } |
|
| 46 |
+ |
|
| 47 |
+ return endpoint, nil |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 50 |
+// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container |
|
| 51 |
+func HotAttachEndpoint(containerID string, endpointID string) error {
|
|
| 52 |
+ return modifyNetworkEndpoint(containerID, endpointID, Add) |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container |
|
| 56 |
+func HotDetachEndpoint(containerID string, endpointID string) error {
|
|
| 57 |
+ return modifyNetworkEndpoint(containerID, endpointID, Remove) |
|
| 58 |
+} |
|
| 59 |
+ |
|
| 60 |
+// ModifyContainer corresponding to the container id, by sending a request |
|
| 61 |
+func modifyContainer(id string, request *ResourceModificationRequestResponse) error {
|
|
| 62 |
+ container, err := OpenContainer(id) |
|
| 63 |
+ if err != nil {
|
|
| 64 |
+ if IsNotExist(err) {
|
|
| 65 |
+ return ErrComputeSystemDoesNotExist |
|
| 66 |
+ } |
|
| 67 |
+ return getInnerError(err) |
|
| 68 |
+ } |
|
| 69 |
+ defer container.Close() |
|
| 70 |
+ err = container.Modify(request) |
|
| 71 |
+ if err != nil {
|
|
| 72 |
+ if IsNotSupported(err) {
|
|
| 73 |
+ return ErrPlatformNotSupported |
|
| 74 |
+ } |
|
| 75 |
+ return getInnerError(err) |
|
| 76 |
+ } |
|
| 77 |
+ |
|
| 78 |
+ return nil |
|
| 79 |
+} |
|
| 80 |
+ |
|
| 81 |
+func modifyNetworkEndpoint(containerID string, endpointID string, request RequestType) error {
|
|
| 82 |
+ requestMessage := &ResourceModificationRequestResponse{
|
|
| 83 |
+ Resource: Network, |
|
| 84 |
+ Request: request, |
|
| 85 |
+ Data: endpointID, |
|
| 86 |
+ } |
|
| 87 |
+ err := modifyContainer(containerID, requestMessage) |
|
| 88 |
+ |
|
| 89 |
+ if err != nil {
|
|
| 90 |
+ return err |
|
| 91 |
+ } |
|
| 92 |
+ |
|
| 93 |
+ return nil |
|
| 94 |
+} |
|
| 95 |
+ |
|
| 96 |
+// GetHNSEndpointByID |
|
| 97 |
+func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
|
|
| 98 |
+ return HNSEndpointRequest("GET", endpointID, "")
|
|
| 99 |
+} |
|
| 100 |
+ |
|
| 101 |
+// GetHNSNetworkName filtered by Name |
|
| 102 |
+func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
|
|
| 103 |
+ hnsResponse, err := HNSListEndpointRequest() |
|
| 104 |
+ if err != nil {
|
|
| 105 |
+ return nil, err |
|
| 106 |
+ } |
|
| 107 |
+ for _, hnsEndpoint := range hnsResponse {
|
|
| 108 |
+ if hnsEndpoint.Name == endpointName {
|
|
| 109 |
+ return &hnsEndpoint, nil |
|
| 110 |
+ } |
|
| 111 |
+ } |
|
| 112 |
+ return nil, fmt.Errorf("Endpoint %v not found", endpointName)
|
|
| 113 |
+} |
|
| 114 |
+ |
|
| 115 |
+// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods |
|
| 116 |
+func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) {
|
|
| 117 |
+ operation := "Create" |
|
| 118 |
+ title := "HCSShim::HNSEndpoint::" + operation |
|
| 119 |
+ logrus.Debugf(title+" id=%s", endpoint.Id) |
|
| 120 |
+ |
|
| 121 |
+ jsonString, err := json.Marshal(endpoint) |
|
| 122 |
+ if err != nil {
|
|
| 123 |
+ return nil, err |
|
| 124 |
+ } |
|
| 125 |
+ return HNSEndpointRequest("POST", "", string(jsonString))
|
|
| 126 |
+} |
|
| 127 |
+ |
|
| 128 |
+// Delete Endpoint by sending EndpointRequest to HNS |
|
| 129 |
+func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) {
|
|
| 130 |
+ operation := "Delete" |
|
| 131 |
+ title := "HCSShim::HNSEndpoint::" + operation |
|
| 132 |
+ logrus.Debugf(title+" id=%s", endpoint.Id) |
|
| 133 |
+ |
|
| 134 |
+ return HNSEndpointRequest("DELETE", endpoint.Id, "")
|
|
| 135 |
+} |
|
| 136 |
+ |
|
| 137 |
+// Delete Endpoint by sending EndpointRequest to HNS |
|
| 138 |
+func (endpoint *HNSEndpoint) Update() (*HNSEndpoint, error) {
|
|
| 139 |
+ operation := "Update" |
|
| 140 |
+ title := "HCSShim::HNSEndpoint::" + operation |
|
| 141 |
+ logrus.Debugf(title+" id=%s", endpoint.Id) |
|
| 142 |
+ jsonString, err := json.Marshal(endpoint) |
|
| 143 |
+ if err != nil {
|
|
| 144 |
+ return nil, err |
|
| 145 |
+ } |
|
| 146 |
+ err = hnsCall("POST", "/endpoints/"+endpoint.Id+"/update", string(jsonString), &endpoint)
|
|
| 147 |
+ |
|
| 148 |
+ return endpoint, err |
|
| 149 |
+} |
|
| 150 |
+ |
|
| 151 |
+// Hot Attach an endpoint to a container |
|
| 152 |
+func (endpoint *HNSEndpoint) HotAttach(containerID string) error {
|
|
| 153 |
+ operation := "HotAttach" |
|
| 154 |
+ title := "HCSShim::HNSEndpoint::" + operation |
|
| 155 |
+ logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID) |
|
| 156 |
+ |
|
| 157 |
+ return modifyNetworkEndpoint(containerID, endpoint.Id, Add) |
|
| 158 |
+} |
|
| 159 |
+ |
|
| 160 |
+// Hot Detach an endpoint from a container |
|
| 161 |
+func (endpoint *HNSEndpoint) HotDetach(containerID string) error {
|
|
| 162 |
+ operation := "HotDetach" |
|
| 163 |
+ title := "HCSShim::HNSEndpoint::" + operation |
|
| 164 |
+ logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID) |
|
| 165 |
+ |
|
| 166 |
+ return modifyNetworkEndpoint(containerID, endpoint.Id, Remove) |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 169 |
+// Apply Acl Policy on the Endpoint |
|
| 170 |
+func (endpoint *HNSEndpoint) ApplyACLPolicy(policy *ACLPolicy) error {
|
|
| 171 |
+ operation := "ApplyACLPolicy" |
|
| 172 |
+ title := "HCSShim::HNSEndpoint::" + operation |
|
| 173 |
+ logrus.Debugf(title+" id=%s", endpoint.Id) |
|
| 174 |
+ |
|
| 175 |
+ jsonString, err := json.Marshal(policy) |
|
| 176 |
+ if err != nil {
|
|
| 177 |
+ return err |
|
| 178 |
+ } |
|
| 179 |
+ endpoint.Policies[0] = jsonString |
|
| 180 |
+ _, err = endpoint.Update() |
|
| 181 |
+ return err |
|
| 182 |
+} |
| ... | ... |
@@ -3,99 +3,10 @@ package hcsshim |
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"fmt" |
| 6 |
- "net" |
|
| 7 | 6 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 7 |
+ "github.com/sirupsen/logrus" |
|
| 9 | 8 |
) |
| 10 | 9 |
|
| 11 |
-type NatPolicy struct {
|
|
| 12 |
- Type string |
|
| 13 |
- Protocol string |
|
| 14 |
- InternalPort uint16 |
|
| 15 |
- ExternalPort uint16 |
|
| 16 |
-} |
|
| 17 |
- |
|
| 18 |
-type QosPolicy struct {
|
|
| 19 |
- Type string |
|
| 20 |
- MaximumOutgoingBandwidthInBytes uint64 |
|
| 21 |
-} |
|
| 22 |
- |
|
| 23 |
-type VlanPolicy struct {
|
|
| 24 |
- Type string |
|
| 25 |
- VLAN uint |
|
| 26 |
-} |
|
| 27 |
- |
|
| 28 |
-type VsidPolicy struct {
|
|
| 29 |
- Type string |
|
| 30 |
- VSID uint |
|
| 31 |
-} |
|
| 32 |
- |
|
| 33 |
-type PaPolicy struct {
|
|
| 34 |
- Type string |
|
| 35 |
- PA string |
|
| 36 |
-} |
|
| 37 |
- |
|
| 38 |
-// Subnet is assoicated with a network and represents a list |
|
| 39 |
-// of subnets available to the network |
|
| 40 |
-type Subnet struct {
|
|
| 41 |
- AddressPrefix string `json:",omitempty"` |
|
| 42 |
- GatewayAddress string `json:",omitempty"` |
|
| 43 |
- Policies []json.RawMessage `json:",omitempty"` |
|
| 44 |
-} |
|
| 45 |
- |
|
| 46 |
-// MacPool is assoicated with a network and represents a list |
|
| 47 |
-// of macaddresses available to the network |
|
| 48 |
-type MacPool struct {
|
|
| 49 |
- StartMacAddress string `json:",omitempty"` |
|
| 50 |
- EndMacAddress string `json:",omitempty"` |
|
| 51 |
-} |
|
| 52 |
- |
|
| 53 |
-// HNSNetwork represents a network in HNS |
|
| 54 |
-type HNSNetwork struct {
|
|
| 55 |
- Id string `json:"ID,omitempty"` |
|
| 56 |
- Name string `json:",omitempty"` |
|
| 57 |
- Type string `json:",omitempty"` |
|
| 58 |
- NetworkAdapterName string `json:",omitempty"` |
|
| 59 |
- SourceMac string `json:",omitempty"` |
|
| 60 |
- Policies []json.RawMessage `json:",omitempty"` |
|
| 61 |
- MacPools []MacPool `json:",omitempty"` |
|
| 62 |
- Subnets []Subnet `json:",omitempty"` |
|
| 63 |
- DNSSuffix string `json:",omitempty"` |
|
| 64 |
- DNSServerList string `json:",omitempty"` |
|
| 65 |
- DNSServerCompartment uint32 `json:",omitempty"` |
|
| 66 |
- ManagementIP string `json:",omitempty"` |
|
| 67 |
-} |
|
| 68 |
- |
|
| 69 |
-// HNSEndpoint represents a network endpoint in HNS |
|
| 70 |
-type HNSEndpoint struct {
|
|
| 71 |
- Id string `json:"ID,omitempty"` |
|
| 72 |
- Name string `json:",omitempty"` |
|
| 73 |
- VirtualNetwork string `json:",omitempty"` |
|
| 74 |
- VirtualNetworkName string `json:",omitempty"` |
|
| 75 |
- Policies []json.RawMessage `json:",omitempty"` |
|
| 76 |
- MacAddress string `json:",omitempty"` |
|
| 77 |
- IPAddress net.IP `json:",omitempty"` |
|
| 78 |
- DNSSuffix string `json:",omitempty"` |
|
| 79 |
- DNSServerList string `json:",omitempty"` |
|
| 80 |
- GatewayAddress string `json:",omitempty"` |
|
| 81 |
- EnableInternalDNS bool `json:",omitempty"` |
|
| 82 |
- DisableICC bool `json:",omitempty"` |
|
| 83 |
- PrefixLength uint8 `json:",omitempty"` |
|
| 84 |
- IsRemoteEndpoint bool `json:",omitempty"` |
|
| 85 |
-} |
|
| 86 |
- |
|
| 87 |
-type hnsNetworkResponse struct {
|
|
| 88 |
- Success bool |
|
| 89 |
- Error string |
|
| 90 |
- Output HNSNetwork |
|
| 91 |
-} |
|
| 92 |
- |
|
| 93 |
-type hnsResponse struct {
|
|
| 94 |
- Success bool |
|
| 95 |
- Error string |
|
| 96 |
- Output json.RawMessage |
|
| 97 |
-} |
|
| 98 |
- |
|
| 99 | 10 |
func hnsCall(method, path, request string, returnResponse interface{}) error {
|
| 100 | 11 |
var responseBuffer *uint16 |
| 101 | 12 |
logrus.Debugf("[%s]=>[%s] Request : %s", method, path, request)
|
| ... | ... |
@@ -127,145 +38,3 @@ func hnsCall(method, path, request string, returnResponse interface{}) error {
|
| 127 | 127 |
|
| 128 | 128 |
return nil |
| 129 | 129 |
} |
| 130 |
- |
|
| 131 |
-// HNSNetworkRequest makes a call into HNS to update/query a single network |
|
| 132 |
-func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
|
|
| 133 |
- var network HNSNetwork |
|
| 134 |
- err := hnsCall(method, "/networks/"+path, request, &network) |
|
| 135 |
- if err != nil {
|
|
| 136 |
- return nil, err |
|
| 137 |
- } |
|
| 138 |
- |
|
| 139 |
- return &network, nil |
|
| 140 |
-} |
|
| 141 |
- |
|
| 142 |
-// HNSListNetworkRequest makes a HNS call to query the list of available networks |
|
| 143 |
-func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
|
|
| 144 |
- var network []HNSNetwork |
|
| 145 |
- err := hnsCall(method, "/networks/"+path, request, &network) |
|
| 146 |
- if err != nil {
|
|
| 147 |
- return nil, err |
|
| 148 |
- } |
|
| 149 |
- |
|
| 150 |
- return network, nil |
|
| 151 |
-} |
|
| 152 |
- |
|
| 153 |
-// HNSEndpointRequest makes a HNS call to modify/query a network endpoint |
|
| 154 |
-func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
|
|
| 155 |
- endpoint := &HNSEndpoint{}
|
|
| 156 |
- err := hnsCall(method, "/endpoints/"+path, request, &endpoint) |
|
| 157 |
- if err != nil {
|
|
| 158 |
- return nil, err |
|
| 159 |
- } |
|
| 160 |
- |
|
| 161 |
- return endpoint, nil |
|
| 162 |
-} |
|
| 163 |
- |
|
| 164 |
-// HNSListEndpointRequest makes a HNS call to query the list of available endpoints |
|
| 165 |
-func HNSListEndpointRequest() ([]HNSEndpoint, error) {
|
|
| 166 |
- var endpoint []HNSEndpoint |
|
| 167 |
- err := hnsCall("GET", "/endpoints/", "", &endpoint)
|
|
| 168 |
- if err != nil {
|
|
| 169 |
- return nil, err |
|
| 170 |
- } |
|
| 171 |
- |
|
| 172 |
- return endpoint, nil |
|
| 173 |
-} |
|
| 174 |
- |
|
| 175 |
-// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container |
|
| 176 |
-func HotAttachEndpoint(containerID string, endpointID string) error {
|
|
| 177 |
- return modifyNetworkEndpoint(containerID, endpointID, Add) |
|
| 178 |
-} |
|
| 179 |
- |
|
| 180 |
-// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container |
|
| 181 |
-func HotDetachEndpoint(containerID string, endpointID string) error {
|
|
| 182 |
- return modifyNetworkEndpoint(containerID, endpointID, Remove) |
|
| 183 |
-} |
|
| 184 |
- |
|
| 185 |
-// ModifyContainer corresponding to the container id, by sending a request |
|
| 186 |
-func modifyContainer(id string, request *ResourceModificationRequestResponse) error {
|
|
| 187 |
- container, err := OpenContainer(id) |
|
| 188 |
- if err != nil {
|
|
| 189 |
- if IsNotExist(err) {
|
|
| 190 |
- return ErrComputeSystemDoesNotExist |
|
| 191 |
- } |
|
| 192 |
- return getInnerError(err) |
|
| 193 |
- } |
|
| 194 |
- defer container.Close() |
|
| 195 |
- err = container.Modify(request) |
|
| 196 |
- if err != nil {
|
|
| 197 |
- if IsNotSupported(err) {
|
|
| 198 |
- return ErrPlatformNotSupported |
|
| 199 |
- } |
|
| 200 |
- return getInnerError(err) |
|
| 201 |
- } |
|
| 202 |
- |
|
| 203 |
- return nil |
|
| 204 |
-} |
|
| 205 |
- |
|
| 206 |
-func modifyNetworkEndpoint(containerID string, endpointID string, request RequestType) error {
|
|
| 207 |
- requestMessage := &ResourceModificationRequestResponse{
|
|
| 208 |
- Resource: Network, |
|
| 209 |
- Request: request, |
|
| 210 |
- Data: endpointID, |
|
| 211 |
- } |
|
| 212 |
- err := modifyContainer(containerID, requestMessage) |
|
| 213 |
- |
|
| 214 |
- if err != nil {
|
|
| 215 |
- return err |
|
| 216 |
- } |
|
| 217 |
- |
|
| 218 |
- return nil |
|
| 219 |
-} |
|
| 220 |
- |
|
| 221 |
-// GetHNSNetworkByID |
|
| 222 |
-func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
|
|
| 223 |
- return HNSNetworkRequest("GET", networkID, "")
|
|
| 224 |
-} |
|
| 225 |
- |
|
| 226 |
-// GetHNSNetworkName filtered by Name |
|
| 227 |
-func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
|
|
| 228 |
- hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
|
|
| 229 |
- if err != nil {
|
|
| 230 |
- return nil, err |
|
| 231 |
- } |
|
| 232 |
- for _, hnsnetwork := range hsnnetworks {
|
|
| 233 |
- if hnsnetwork.Name == networkName {
|
|
| 234 |
- return &hnsnetwork, nil |
|
| 235 |
- } |
|
| 236 |
- } |
|
| 237 |
- return nil, fmt.Errorf("Network %v not found", networkName)
|
|
| 238 |
-} |
|
| 239 |
- |
|
| 240 |
-// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods |
|
| 241 |
-func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) {
|
|
| 242 |
- jsonString, err := json.Marshal(endpoint) |
|
| 243 |
- if err != nil {
|
|
| 244 |
- return nil, err |
|
| 245 |
- } |
|
| 246 |
- return HNSEndpointRequest("POST", "", string(jsonString))
|
|
| 247 |
-} |
|
| 248 |
- |
|
| 249 |
-// Create Endpoint by sending EndpointRequest to HNS |
|
| 250 |
-func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) {
|
|
| 251 |
- return HNSEndpointRequest("DELETE", endpoint.Id, "")
|
|
| 252 |
-} |
|
| 253 |
- |
|
| 254 |
-// GetHNSEndpointByID |
|
| 255 |
-func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
|
|
| 256 |
- return HNSEndpointRequest("GET", endpointID, "")
|
|
| 257 |
-} |
|
| 258 |
- |
|
| 259 |
-// GetHNSNetworkName filtered by Name |
|
| 260 |
-func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
|
|
| 261 |
- hnsResponse, err := HNSListEndpointRequest() |
|
| 262 |
- if err != nil {
|
|
| 263 |
- return nil, err |
|
| 264 |
- } |
|
| 265 |
- for _, hnsEndpoint := range hnsResponse {
|
|
| 266 |
- if hnsEndpoint.Name == endpointName {
|
|
| 267 |
- return &hnsEndpoint, nil |
|
| 268 |
- } |
|
| 269 |
- } |
|
| 270 |
- return nil, fmt.Errorf("Endpoint %v not found", endpointName)
|
|
| 271 |
-} |
| 272 | 130 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,142 @@ |
| 0 |
+package hcsshim |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "encoding/json" |
|
| 4 |
+ "fmt" |
|
| 5 |
+ "net" |
|
| 6 |
+ |
|
| 7 |
+ "github.com/sirupsen/logrus" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+// Subnet is assoicated with a network and represents a list |
|
| 11 |
+// of subnets available to the network |
|
| 12 |
+type Subnet struct {
|
|
| 13 |
+ AddressPrefix string `json:",omitempty"` |
|
| 14 |
+ GatewayAddress string `json:",omitempty"` |
|
| 15 |
+ Policies []json.RawMessage `json:",omitempty"` |
|
| 16 |
+} |
|
| 17 |
+ |
|
| 18 |
+// MacPool is assoicated with a network and represents a list |
|
| 19 |
+// of macaddresses available to the network |
|
| 20 |
+type MacPool struct {
|
|
| 21 |
+ StartMacAddress string `json:",omitempty"` |
|
| 22 |
+ EndMacAddress string `json:",omitempty"` |
|
| 23 |
+} |
|
| 24 |
+ |
|
| 25 |
+// HNSNetwork represents a network in HNS |
|
| 26 |
+type HNSNetwork struct {
|
|
| 27 |
+ Id string `json:"ID,omitempty"` |
|
| 28 |
+ Name string `json:",omitempty"` |
|
| 29 |
+ Type string `json:",omitempty"` |
|
| 30 |
+ NetworkAdapterName string `json:",omitempty"` |
|
| 31 |
+ SourceMac string `json:",omitempty"` |
|
| 32 |
+ Policies []json.RawMessage `json:",omitempty"` |
|
| 33 |
+ MacPools []MacPool `json:",omitempty"` |
|
| 34 |
+ Subnets []Subnet `json:",omitempty"` |
|
| 35 |
+ DNSSuffix string `json:",omitempty"` |
|
| 36 |
+ DNSServerList string `json:",omitempty"` |
|
| 37 |
+ DNSServerCompartment uint32 `json:",omitempty"` |
|
| 38 |
+ ManagementIP string `json:",omitempty"` |
|
| 39 |
+ AutomaticDNS bool `json:",omitempty"` |
|
| 40 |
+} |
|
| 41 |
+ |
|
| 42 |
+type hnsNetworkResponse struct {
|
|
| 43 |
+ Success bool |
|
| 44 |
+ Error string |
|
| 45 |
+ Output HNSNetwork |
|
| 46 |
+} |
|
| 47 |
+ |
|
| 48 |
+type hnsResponse struct {
|
|
| 49 |
+ Success bool |
|
| 50 |
+ Error string |
|
| 51 |
+ Output json.RawMessage |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+// HNSNetworkRequest makes a call into HNS to update/query a single network |
|
| 55 |
+func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
|
|
| 56 |
+ var network HNSNetwork |
|
| 57 |
+ err := hnsCall(method, "/networks/"+path, request, &network) |
|
| 58 |
+ if err != nil {
|
|
| 59 |
+ return nil, err |
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ return &network, nil |
|
| 63 |
+} |
|
| 64 |
+ |
|
| 65 |
+// HNSListNetworkRequest makes a HNS call to query the list of available networks |
|
| 66 |
+func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
|
|
| 67 |
+ var network []HNSNetwork |
|
| 68 |
+ err := hnsCall(method, "/networks/"+path, request, &network) |
|
| 69 |
+ if err != nil {
|
|
| 70 |
+ return nil, err |
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ return network, nil |
|
| 74 |
+} |
|
| 75 |
+ |
|
| 76 |
+// GetHNSNetworkByID |
|
| 77 |
+func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
|
|
| 78 |
+ return HNSNetworkRequest("GET", networkID, "")
|
|
| 79 |
+} |
|
| 80 |
+ |
|
| 81 |
+// GetHNSNetworkName filtered by Name |
|
| 82 |
+func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
|
|
| 83 |
+ hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
|
|
| 84 |
+ if err != nil {
|
|
| 85 |
+ return nil, err |
|
| 86 |
+ } |
|
| 87 |
+ for _, hnsnetwork := range hsnnetworks {
|
|
| 88 |
+ if hnsnetwork.Name == networkName {
|
|
| 89 |
+ return &hnsnetwork, nil |
|
| 90 |
+ } |
|
| 91 |
+ } |
|
| 92 |
+ return nil, fmt.Errorf("Network %v not found", networkName)
|
|
| 93 |
+} |
|
| 94 |
+ |
|
| 95 |
+// Create Network by sending NetworkRequest to HNS. |
|
| 96 |
+func (network *HNSNetwork) Create() (*HNSNetwork, error) {
|
|
| 97 |
+ operation := "Create" |
|
| 98 |
+ title := "HCSShim::HNSNetwork::" + operation |
|
| 99 |
+ logrus.Debugf(title+" id=%s", network.Id) |
|
| 100 |
+ |
|
| 101 |
+ jsonString, err := json.Marshal(network) |
|
| 102 |
+ if err != nil {
|
|
| 103 |
+ return nil, err |
|
| 104 |
+ } |
|
| 105 |
+ return HNSNetworkRequest("POST", "", string(jsonString))
|
|
| 106 |
+} |
|
| 107 |
+ |
|
| 108 |
+// Delete Network by sending NetworkRequest to HNS |
|
| 109 |
+func (network *HNSNetwork) Delete() (*HNSNetwork, error) {
|
|
| 110 |
+ operation := "Delete" |
|
| 111 |
+ title := "HCSShim::HNSNetwork::" + operation |
|
| 112 |
+ logrus.Debugf(title+" id=%s", network.Id) |
|
| 113 |
+ |
|
| 114 |
+ return HNSNetworkRequest("DELETE", network.Id, "")
|
|
| 115 |
+} |
|
| 116 |
+ |
|
| 117 |
+// Creates an endpoint on the Network. |
|
| 118 |
+func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint {
|
|
| 119 |
+ return &HNSEndpoint{
|
|
| 120 |
+ VirtualNetwork: network.Id, |
|
| 121 |
+ IPAddress: ipAddress, |
|
| 122 |
+ MacAddress: string(macAddress), |
|
| 123 |
+ } |
|
| 124 |
+} |
|
| 125 |
+ |
|
| 126 |
+func (network *HNSNetwork) CreateEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
|
|
| 127 |
+ operation := "CreateEndpoint" |
|
| 128 |
+ title := "HCSShim::HNSNetwork::" + operation |
|
| 129 |
+ logrus.Debugf(title+" id=%s, endpointId=%s", network.Id, endpoint.Id) |
|
| 130 |
+ |
|
| 131 |
+ endpoint.VirtualNetwork = network.Id |
|
| 132 |
+ return endpoint.Create() |
|
| 133 |
+} |
|
| 134 |
+ |
|
| 135 |
+func (network *HNSNetwork) CreateRemoteEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
|
|
| 136 |
+ operation := "CreateRemoteEndpoint" |
|
| 137 |
+ title := "HCSShim::HNSNetwork::" + operation |
|
| 138 |
+ logrus.Debugf(title+" id=%s", network.Id) |
|
| 139 |
+ endpoint.IsRemoteEndpoint = true |
|
| 140 |
+ return network.CreateEndpoint(endpoint) |
|
| 141 |
+} |
| 0 | 142 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,95 @@ |
| 0 |
+package hcsshim |
|
| 1 |
+ |
|
| 2 |
+// Type of Request Support in ModifySystem |
|
| 3 |
+type PolicyType string |
|
| 4 |
+ |
|
| 5 |
+// RequestType const |
|
| 6 |
+const ( |
|
| 7 |
+ Nat PolicyType = "NAT" |
|
| 8 |
+ ACL PolicyType = "ACL" |
|
| 9 |
+ PA PolicyType = "PA" |
|
| 10 |
+ VLAN PolicyType = "VLAN" |
|
| 11 |
+ VSID PolicyType = "VSID" |
|
| 12 |
+ VNet PolicyType = "VNET" |
|
| 13 |
+ L2Driver PolicyType = "L2Driver" |
|
| 14 |
+ Isolation PolicyType = "Isolation" |
|
| 15 |
+ QOS PolicyType = "QOS" |
|
| 16 |
+ OutboundNat PolicyType = "OutBoundNAT" |
|
| 17 |
+ ExternalLoadBalancer PolicyType = "ELB" |
|
| 18 |
+ Route PolicyType = "ROUTE" |
|
| 19 |
+) |
|
| 20 |
+ |
|
| 21 |
+type NatPolicy struct {
|
|
| 22 |
+ Type PolicyType `json:"Type"` |
|
| 23 |
+ Protocol string |
|
| 24 |
+ InternalPort uint16 |
|
| 25 |
+ ExternalPort uint16 |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+type QosPolicy struct {
|
|
| 29 |
+ Type PolicyType `json:"Type"` |
|
| 30 |
+ MaximumOutgoingBandwidthInBytes uint64 |
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+type IsolationPolicy struct {
|
|
| 34 |
+ Type PolicyType `json:"Type"` |
|
| 35 |
+ VLAN uint |
|
| 36 |
+ VSID uint |
|
| 37 |
+ InDefaultIsolation bool |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+type VlanPolicy struct {
|
|
| 41 |
+ Type PolicyType `json:"Type"` |
|
| 42 |
+ VLAN uint |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+type VsidPolicy struct {
|
|
| 46 |
+ Type PolicyType `json:"Type"` |
|
| 47 |
+ VSID uint |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 50 |
+type PaPolicy struct {
|
|
| 51 |
+ Type PolicyType `json:"Type"` |
|
| 52 |
+ PA string `json:"PA"` |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+type OutboundNatPolicy struct {
|
|
| 56 |
+ Policy |
|
| 57 |
+ VIP string `json:"VIP,omitempty"` |
|
| 58 |
+ Exceptions []string `json:"ExceptionList,omitempty"` |
|
| 59 |
+} |
|
| 60 |
+ |
|
| 61 |
+type ActionType string |
|
| 62 |
+type DirectionType string |
|
| 63 |
+type RuleType string |
|
| 64 |
+ |
|
| 65 |
+const ( |
|
| 66 |
+ Allow ActionType = "Allow" |
|
| 67 |
+ Block ActionType = "Block" |
|
| 68 |
+ |
|
| 69 |
+ In DirectionType = "In" |
|
| 70 |
+ Out DirectionType = "Out" |
|
| 71 |
+ |
|
| 72 |
+ Host RuleType = "Host" |
|
| 73 |
+ Switch RuleType = "Switch" |
|
| 74 |
+) |
|
| 75 |
+ |
|
| 76 |
+type ACLPolicy struct {
|
|
| 77 |
+ Type PolicyType `json:"Type"` |
|
| 78 |
+ Protocol uint16 |
|
| 79 |
+ InternalPort uint16 |
|
| 80 |
+ Action ActionType |
|
| 81 |
+ Direction DirectionType |
|
| 82 |
+ LocalAddress string |
|
| 83 |
+ RemoteAddress string |
|
| 84 |
+ LocalPort uint16 |
|
| 85 |
+ RemotePort uint16 |
|
| 86 |
+ RuleType RuleType `json:"RuleType,omitempty"` |
|
| 87 |
+ |
|
| 88 |
+ Priority uint16 |
|
| 89 |
+ ServiceName string |
|
| 90 |
+} |
|
| 91 |
+ |
|
| 92 |
+type Policy struct {
|
|
| 93 |
+ Type PolicyType `json:"Type"` |
|
| 94 |
+} |
| 0 | 95 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,187 @@ |
| 0 |
+package hcsshim |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "encoding/json" |
|
| 4 |
+ |
|
| 5 |
+ "github.com/sirupsen/logrus" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+type RoutePolicy struct {
|
|
| 9 |
+ Policy |
|
| 10 |
+ DestinationPrefix string `json:"DestinationPrefix,omitempty"` |
|
| 11 |
+ NextHop string `json:"NextHop,omitempty"` |
|
| 12 |
+ EncapEnabled bool `json:"NeedEncap,omitempty"` |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 15 |
+type ELBPolicy struct {
|
|
| 16 |
+ LBPolicy |
|
| 17 |
+ SourceVIP string `json:"SourceVIP,omitempty"` |
|
| 18 |
+ VIPs []string `json:"VIPs,omitempty"` |
|
| 19 |
+ ILB bool `json:"ILB,omitempty"` |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 22 |
+type LBPolicy struct {
|
|
| 23 |
+ Policy |
|
| 24 |
+ Protocol uint16 `json:"Protocol,omitempty"` |
|
| 25 |
+ InternalPort uint16 |
|
| 26 |
+ ExternalPort uint16 |
|
| 27 |
+} |
|
| 28 |
+ |
|
| 29 |
+type PolicyList struct {
|
|
| 30 |
+ Id string `json:"ID,omitempty"` |
|
| 31 |
+ EndpointReferences []string `json:"References,omitempty"` |
|
| 32 |
+ Policies []string `json:"Policies,omitempty"` |
|
| 33 |
+} |
|
| 34 |
+ |
|
| 35 |
+// HNSPolicyListRequest makes a call into HNS to update/query a single network |
|
| 36 |
+func HNSPolicyListRequest(method, path, request string) (*PolicyList, error) {
|
|
| 37 |
+ var policy PolicyList |
|
| 38 |
+ err := hnsCall(method, "/policylists/"+path, request, &policy) |
|
| 39 |
+ if err != nil {
|
|
| 40 |
+ return nil, err |
|
| 41 |
+ } |
|
| 42 |
+ |
|
| 43 |
+ return &policy, nil |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+func HNSListPolicyListRequest() ([]PolicyList, error) {
|
|
| 47 |
+ var plist []PolicyList |
|
| 48 |
+ err := hnsCall("GET", "/policylists/", "", &plist)
|
|
| 49 |
+ if err != nil {
|
|
| 50 |
+ return nil, err |
|
| 51 |
+ } |
|
| 52 |
+ |
|
| 53 |
+ return plist, nil |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+// PolicyListRequest makes a HNS call to modify/query a network endpoint |
|
| 57 |
+func PolicyListRequest(method, path, request string) (*PolicyList, error) {
|
|
| 58 |
+ policylist := &PolicyList{}
|
|
| 59 |
+ err := hnsCall(method, "/policylists/"+path, request, &policylist) |
|
| 60 |
+ if err != nil {
|
|
| 61 |
+ return nil, err |
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ return policylist, nil |
|
| 65 |
+} |
|
| 66 |
+ |
|
| 67 |
+// Create PolicyList by sending PolicyListRequest to HNS. |
|
| 68 |
+func (policylist *PolicyList) Create() (*PolicyList, error) {
|
|
| 69 |
+ operation := "Create" |
|
| 70 |
+ title := "HCSShim::PolicyList::" + operation |
|
| 71 |
+ logrus.Debugf(title+" id=%s", policylist.Id) |
|
| 72 |
+ jsonString, err := json.Marshal(policylist) |
|
| 73 |
+ if err != nil {
|
|
| 74 |
+ return nil, err |
|
| 75 |
+ } |
|
| 76 |
+ return PolicyListRequest("POST", "", string(jsonString))
|
|
| 77 |
+} |
|
| 78 |
+ |
|
| 79 |
+// Create PolicyList by sending PolicyListRequest to HNS |
|
| 80 |
+func (policylist *PolicyList) Delete() (*PolicyList, error) {
|
|
| 81 |
+ operation := "Delete" |
|
| 82 |
+ title := "HCSShim::PolicyList::" + operation |
|
| 83 |
+ logrus.Debugf(title+" id=%s", policylist.Id) |
|
| 84 |
+ |
|
| 85 |
+ return PolicyListRequest("DELETE", policylist.Id, "")
|
|
| 86 |
+} |
|
| 87 |
+ |
|
| 88 |
+// Add an endpoint to a Policy List |
|
| 89 |
+func (policylist *PolicyList) AddEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
|
|
| 90 |
+ operation := "AddEndpoint" |
|
| 91 |
+ title := "HCSShim::PolicyList::" + operation |
|
| 92 |
+ logrus.Debugf(title+" id=%s, endpointId:%s", policylist.Id, endpoint.Id) |
|
| 93 |
+ |
|
| 94 |
+ _, err := policylist.Delete() |
|
| 95 |
+ if err != nil {
|
|
| 96 |
+ return nil, err |
|
| 97 |
+ } |
|
| 98 |
+ |
|
| 99 |
+ // Add Endpoint to the Existing List |
|
| 100 |
+ policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id) |
|
| 101 |
+ |
|
| 102 |
+ return policylist.Create() |
|
| 103 |
+} |
|
| 104 |
+ |
|
| 105 |
+// Remove an endpoint from the Policy List |
|
| 106 |
+func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
|
|
| 107 |
+ operation := "RemoveEndpoint" |
|
| 108 |
+ title := "HCSShim::PolicyList::" + operation |
|
| 109 |
+ logrus.Debugf(title+" id=%s, endpointId:%s", policylist.Id, endpoint.Id) |
|
| 110 |
+ |
|
| 111 |
+ _, err := policylist.Delete() |
|
| 112 |
+ if err != nil {
|
|
| 113 |
+ return nil, err |
|
| 114 |
+ } |
|
| 115 |
+ |
|
| 116 |
+ elementToRemove := "/endpoints/" + endpoint.Id |
|
| 117 |
+ |
|
| 118 |
+ var references []string |
|
| 119 |
+ |
|
| 120 |
+ for _, endpointReference := range policylist.EndpointReferences {
|
|
| 121 |
+ if endpointReference == elementToRemove {
|
|
| 122 |
+ continue |
|
| 123 |
+ } |
|
| 124 |
+ references = append(references, endpointReference) |
|
| 125 |
+ } |
|
| 126 |
+ policylist.EndpointReferences = references |
|
| 127 |
+ return policylist.Create() |
|
| 128 |
+} |
|
| 129 |
+ |
|
| 130 |
+// AddLoadBalancer policy list for the specified endpoints |
|
| 131 |
+func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) {
|
|
| 132 |
+ operation := "AddLoadBalancer" |
|
| 133 |
+ title := "HCSShim::PolicyList::" + operation |
|
| 134 |
+ logrus.Debugf(title+" Vip:%s", vip) |
|
| 135 |
+ |
|
| 136 |
+ policylist := &PolicyList{}
|
|
| 137 |
+ |
|
| 138 |
+ elbPolicy := &ELBPolicy{
|
|
| 139 |
+ VIPs: []string{vip},
|
|
| 140 |
+ ILB: isILB, |
|
| 141 |
+ } |
|
| 142 |
+ elbPolicy.Type = ExternalLoadBalancer |
|
| 143 |
+ elbPolicy.Protocol = protocol |
|
| 144 |
+ elbPolicy.InternalPort = internalPort |
|
| 145 |
+ elbPolicy.ExternalPort = externalPort |
|
| 146 |
+ |
|
| 147 |
+ for _, endpoint := range endpoints {
|
|
| 148 |
+ policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id) |
|
| 149 |
+ } |
|
| 150 |
+ |
|
| 151 |
+ jsonString, err := json.Marshal(elbPolicy) |
|
| 152 |
+ if err != nil {
|
|
| 153 |
+ return nil, err |
|
| 154 |
+ } |
|
| 155 |
+ |
|
| 156 |
+ policylist.Policies[0] = string(jsonString) |
|
| 157 |
+ return policylist.Create() |
|
| 158 |
+} |
|
| 159 |
+ |
|
| 160 |
+// AddLoadBalancer policy list for the specified endpoints |
|
| 161 |
+func AddRoute(endpoints []HNSEndpoint, destinationPrefix string, nextHop string, encapEnabled bool) (*PolicyList, error) {
|
|
| 162 |
+ operation := "AddRoute" |
|
| 163 |
+ title := "HCSShim::PolicyList::" + operation |
|
| 164 |
+ logrus.Debugf(title+" destinationPrefix:%s", destinationPrefix) |
|
| 165 |
+ |
|
| 166 |
+ policylist := &PolicyList{}
|
|
| 167 |
+ |
|
| 168 |
+ rPolicy := &RoutePolicy{
|
|
| 169 |
+ DestinationPrefix: destinationPrefix, |
|
| 170 |
+ NextHop: nextHop, |
|
| 171 |
+ EncapEnabled: encapEnabled, |
|
| 172 |
+ } |
|
| 173 |
+ rPolicy.Type = Route |
|
| 174 |
+ |
|
| 175 |
+ for _, endpoint := range endpoints {
|
|
| 176 |
+ policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id) |
|
| 177 |
+ } |
|
| 178 |
+ |
|
| 179 |
+ jsonString, err := json.Marshal(rPolicy) |
|
| 180 |
+ if err != nil {
|
|
| 181 |
+ return nil, err |
|
| 182 |
+ } |
|
| 183 |
+ |
|
| 184 |
+ policylist.Policies[0] = string(jsonString) |
|
| 185 |
+ return policylist.Create() |
|
| 186 |
+} |
| ... | ... |
@@ -37,11 +37,17 @@ type MappedDir struct {
|
| 37 | 37 |
IOPSMaximum uint64 |
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 |
+type MappedPipe struct {
|
|
| 41 |
+ HostPath string |
|
| 42 |
+ ContainerPipeName string |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 40 | 45 |
type HvRuntime struct {
|
| 41 |
- ImagePath string `json:",omitempty"` |
|
| 42 |
- SkipTemplate bool `json:",omitempty"` |
|
| 43 |
- LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM |
|
| 44 |
- LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM |
|
| 46 |
+ ImagePath string `json:",omitempty"` |
|
| 47 |
+ SkipTemplate bool `json:",omitempty"` |
|
| 48 |
+ LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM |
|
| 49 |
+ LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM |
|
| 50 |
+ LinuxBootParameters string `json:",omitempty"` // Additional boot parameters for starting a Linux Utility VM in initrd mode |
|
| 45 | 51 |
} |
| 46 | 52 |
|
| 47 | 53 |
type MappedVirtualDisk struct {
|
| ... | ... |
@@ -50,6 +56,7 @@ type MappedVirtualDisk struct {
|
| 50 | 50 |
CreateInUtilityVM bool `json:",omitempty"` |
| 51 | 51 |
ReadOnly bool `json:",omitempty"` |
| 52 | 52 |
Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing" |
| 53 |
+ AttachOnly bool `json:",omitempty:` |
|
| 53 | 54 |
} |
| 54 | 55 |
|
| 55 | 56 |
// ContainerConfig is used as both the input of CreateContainer |
| ... | ... |
@@ -64,14 +71,15 @@ type ContainerConfig struct {
|
| 64 | 64 |
Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID |
| 65 | 65 |
Credentials string `json:",omitempty"` // Credentials information |
| 66 | 66 |
ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container. |
| 67 |
- ProcessorWeight uint64 `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default. |
|
| 68 |
- ProcessorMaximum int64 `json:",omitempty"` // CPU maximum usage percent 1..100 |
|
| 67 |
+ ProcessorWeight uint64 `json:",omitempty"` // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. A value of 0 results in default shares. |
|
| 68 |
+ ProcessorMaximum int64 `json:",omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Range is from 1 to 10000. A value of 0 results in no limit. |
|
| 69 | 69 |
StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS |
| 70 | 70 |
StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second |
| 71 | 71 |
StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller |
| 72 | 72 |
MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes |
| 73 | 73 |
HostName string `json:",omitempty"` // Hostname |
| 74 | 74 |
MappedDirectories []MappedDir `json:",omitempty"` // List of mapped directories (volumes/mounts) |
| 75 |
+ MappedPipes []MappedPipe `json:",omitempty"` // List of mapped Windows named pipes |
|
| 75 | 76 |
HvPartition bool // True if it a Hyper-V Container |
| 76 | 77 |
NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with. |
| 77 | 78 |
EndpointList []string `json:",omitempty"` // List of networking endpoints to be attached to container |
| ... | ... |
@@ -124,6 +132,9 @@ type Container interface {
|
| 124 | 124 |
// ProcessList returns details for the processes in a container. |
| 125 | 125 |
ProcessList() ([]ProcessListItem, error) |
| 126 | 126 |
|
| 127 |
+ // MappedVirtualDisks returns virtual disks mapped to a utility VM, indexed by controller |
|
| 128 |
+ MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) |
|
| 129 |
+ |
|
| 127 | 130 |
// CreateProcess launches a new process within the container. |
| 128 | 131 |
CreateProcess(c *ProcessConfig) (Process, error) |
| 129 | 132 |
|
| 10 | 10 |
deleted file mode 100644 |
| ... | ... |
@@ -1,21 +0,0 @@ |
| 1 |
-The MIT License (MIT) |
|
| 2 |
- |
|
| 3 |
-Copyright (c) 2014 Simon Eskildsen |
|
| 4 |
- |
|
| 5 |
-Permission is hereby granted, free of charge, to any person obtaining a copy |
|
| 6 |
-of this software and associated documentation files (the "Software"), to deal |
|
| 7 |
-in the Software without restriction, including without limitation the rights |
|
| 8 |
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
| 9 |
-copies of the Software, and to permit persons to whom the Software is |
|
| 10 |
-furnished to do so, subject to the following conditions: |
|
| 11 |
- |
|
| 12 |
-The above copyright notice and this permission notice shall be included in |
|
| 13 |
-all copies or substantial portions of the Software. |
|
| 14 |
- |
|
| 15 |
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 16 |
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 17 |
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
| 18 |
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 19 |
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
| 20 |
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
| 21 |
-THE SOFTWARE. |
| 22 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,425 +0,0 @@ |
| 1 |
-# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [](https://travis-ci.org/Sirupsen/logrus) [](https://godoc.org/github.com/Sirupsen/logrus) |
|
| 2 |
- |
|
| 3 |
-Logrus is a structured logger for Go (golang), completely API compatible with |
|
| 4 |
-the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not |
|
| 5 |
-yet stable (pre 1.0). Logrus itself is completely stable and has been used in |
|
| 6 |
-many large deployments. The core API is unlikely to change much but please |
|
| 7 |
-version control your Logrus to make sure you aren't fetching latest `master` on |
|
| 8 |
-every build.** |
|
| 9 |
- |
|
| 10 |
-Nicely color-coded in development (when a TTY is attached, otherwise just |
|
| 11 |
-plain text): |
|
| 12 |
- |
|
| 13 |
- |
|
| 14 |
- |
|
| 15 |
-With `log.SetFormatter(&log.JSONFormatter{})`, for easy parsing by logstash
|
|
| 16 |
-or Splunk: |
|
| 17 |
- |
|
| 18 |
-```json |
|
| 19 |
-{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
|
|
| 20 |
-ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"} |
|
| 21 |
- |
|
| 22 |
-{"level":"warning","msg":"The group's number increased tremendously!",
|
|
| 23 |
-"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"} |
|
| 24 |
- |
|
| 25 |
-{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
|
|
| 26 |
-"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"} |
|
| 27 |
- |
|
| 28 |
-{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
|
|
| 29 |
-"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"} |
|
| 30 |
- |
|
| 31 |
-{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
|
|
| 32 |
-"time":"2014-03-10 19:57:38.562543128 -0400 EDT"} |
|
| 33 |
-``` |
|
| 34 |
- |
|
| 35 |
-With the default `log.SetFormatter(&log.TextFormatter{})` when a TTY is not
|
|
| 36 |
-attached, the output is compatible with the |
|
| 37 |
-[logfmt](http://godoc.org/github.com/kr/logfmt) format: |
|
| 38 |
- |
|
| 39 |
-```text |
|
| 40 |
-time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8 |
|
| 41 |
-time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10 |
|
| 42 |
-time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true |
|
| 43 |
-time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4 |
|
| 44 |
-time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 |
|
| 45 |
-time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
|
|
| 46 |
-exit status 1 |
|
| 47 |
-``` |
|
| 48 |
- |
|
| 49 |
-#### Example |
|
| 50 |
- |
|
| 51 |
-The simplest way to use Logrus is simply the package-level exported logger: |
|
| 52 |
- |
|
| 53 |
-```go |
|
| 54 |
-package main |
|
| 55 |
- |
|
| 56 |
-import ( |
|
| 57 |
- log "github.com/Sirupsen/logrus" |
|
| 58 |
-) |
|
| 59 |
- |
|
| 60 |
-func main() {
|
|
| 61 |
- log.WithFields(log.Fields{
|
|
| 62 |
- "animal": "walrus", |
|
| 63 |
- }).Info("A walrus appears")
|
|
| 64 |
-} |
|
| 65 |
-``` |
|
| 66 |
- |
|
| 67 |
-Note that it's completely api-compatible with the stdlib logger, so you can |
|
| 68 |
-replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"` |
|
| 69 |
-and you'll now have the flexibility of Logrus. You can customize it all you |
|
| 70 |
-want: |
|
| 71 |
- |
|
| 72 |
-```go |
|
| 73 |
-package main |
|
| 74 |
- |
|
| 75 |
-import ( |
|
| 76 |
- "os" |
|
| 77 |
- log "github.com/Sirupsen/logrus" |
|
| 78 |
-) |
|
| 79 |
- |
|
| 80 |
-func init() {
|
|
| 81 |
- // Log as JSON instead of the default ASCII formatter. |
|
| 82 |
- log.SetFormatter(&log.JSONFormatter{})
|
|
| 83 |
- |
|
| 84 |
- // Output to stderr instead of stdout, could also be a file. |
|
| 85 |
- log.SetOutput(os.Stderr) |
|
| 86 |
- |
|
| 87 |
- // Only log the warning severity or above. |
|
| 88 |
- log.SetLevel(log.WarnLevel) |
|
| 89 |
-} |
|
| 90 |
- |
|
| 91 |
-func main() {
|
|
| 92 |
- log.WithFields(log.Fields{
|
|
| 93 |
- "animal": "walrus", |
|
| 94 |
- "size": 10, |
|
| 95 |
- }).Info("A group of walrus emerges from the ocean")
|
|
| 96 |
- |
|
| 97 |
- log.WithFields(log.Fields{
|
|
| 98 |
- "omg": true, |
|
| 99 |
- "number": 122, |
|
| 100 |
- }).Warn("The group's number increased tremendously!")
|
|
| 101 |
- |
|
| 102 |
- log.WithFields(log.Fields{
|
|
| 103 |
- "omg": true, |
|
| 104 |
- "number": 100, |
|
| 105 |
- }).Fatal("The ice breaks!")
|
|
| 106 |
- |
|
| 107 |
- // A common pattern is to re-use fields between logging statements by re-using |
|
| 108 |
- // the logrus.Entry returned from WithFields() |
|
| 109 |
- contextLogger := log.WithFields(log.Fields{
|
|
| 110 |
- "common": "this is a common field", |
|
| 111 |
- "other": "I also should be logged always", |
|
| 112 |
- }) |
|
| 113 |
- |
|
| 114 |
- contextLogger.Info("I'll be logged with common and other field")
|
|
| 115 |
- contextLogger.Info("Me too")
|
|
| 116 |
-} |
|
| 117 |
-``` |
|
| 118 |
- |
|
| 119 |
-For more advanced usage such as logging to multiple locations from the same |
|
| 120 |
-application, you can also create an instance of the `logrus` Logger: |
|
| 121 |
- |
|
| 122 |
-```go |
|
| 123 |
-package main |
|
| 124 |
- |
|
| 125 |
-import ( |
|
| 126 |
- "github.com/Sirupsen/logrus" |
|
| 127 |
-) |
|
| 128 |
- |
|
| 129 |
-// Create a new instance of the logger. You can have any number of instances. |
|
| 130 |
-var log = logrus.New() |
|
| 131 |
- |
|
| 132 |
-func main() {
|
|
| 133 |
- // The API for setting attributes is a little different than the package level |
|
| 134 |
- // exported logger. See Godoc. |
|
| 135 |
- log.Out = os.Stderr |
|
| 136 |
- |
|
| 137 |
- log.WithFields(logrus.Fields{
|
|
| 138 |
- "animal": "walrus", |
|
| 139 |
- "size": 10, |
|
| 140 |
- }).Info("A group of walrus emerges from the ocean")
|
|
| 141 |
-} |
|
| 142 |
-``` |
|
| 143 |
- |
|
| 144 |
-#### Fields |
|
| 145 |
- |
|
| 146 |
-Logrus encourages careful, structured logging though logging fields instead of |
|
| 147 |
-long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
|
|
| 148 |
-to send event %s to topic %s with key %d")`, you should log the much more |
|
| 149 |
-discoverable: |
|
| 150 |
- |
|
| 151 |
-```go |
|
| 152 |
-log.WithFields(log.Fields{
|
|
| 153 |
- "event": event, |
|
| 154 |
- "topic": topic, |
|
| 155 |
- "key": key, |
|
| 156 |
-}).Fatal("Failed to send event")
|
|
| 157 |
-``` |
|
| 158 |
- |
|
| 159 |
-We've found this API forces you to think about logging in a way that produces |
|
| 160 |
-much more useful logging messages. We've been in countless situations where just |
|
| 161 |
-a single added field to a log statement that was already there would've saved us |
|
| 162 |
-hours. The `WithFields` call is optional. |
|
| 163 |
- |
|
| 164 |
-In general, with Logrus using any of the `printf`-family functions should be |
|
| 165 |
-seen as a hint you should add a field, however, you can still use the |
|
| 166 |
-`printf`-family functions with Logrus. |
|
| 167 |
- |
|
| 168 |
-#### Hooks |
|
| 169 |
- |
|
| 170 |
-You can add hooks for logging levels. For example to send errors to an exception |
|
| 171 |
-tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to |
|
| 172 |
-multiple places simultaneously, e.g. syslog. |
|
| 173 |
- |
|
| 174 |
-Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in |
|
| 175 |
-`init`: |
|
| 176 |
- |
|
| 177 |
-```go |
|
| 178 |
-import ( |
|
| 179 |
- log "github.com/Sirupsen/logrus" |
|
| 180 |
- "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake" |
|
| 181 |
- logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" |
|
| 182 |
- "log/syslog" |
|
| 183 |
-) |
|
| 184 |
- |
|
| 185 |
-func init() {
|
|
| 186 |
- |
|
| 187 |
- // Use the Airbrake hook to report errors that have Error severity or above to |
|
| 188 |
- // an exception tracker. You can create custom hooks, see the Hooks section. |
|
| 189 |
- log.AddHook(airbrake.NewHook(123, "xyz", "production")) |
|
| 190 |
- |
|
| 191 |
- hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
|
|
| 192 |
- if err != nil {
|
|
| 193 |
- log.Error("Unable to connect to local syslog daemon")
|
|
| 194 |
- } else {
|
|
| 195 |
- log.AddHook(hook) |
|
| 196 |
- } |
|
| 197 |
-} |
|
| 198 |
-``` |
|
| 199 |
-Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md). |
|
| 200 |
- |
|
| 201 |
-| Hook | Description | |
|
| 202 |
-| ----- | ----------- | |
|
| 203 |
-| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. | |
|
| 204 |
-| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. | |
|
| 205 |
-| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. | |
|
| 206 |
-| [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. | |
|
| 207 |
-| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | |
|
| 208 |
-| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. | |
|
| 209 |
-| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | |
|
| 210 |
-| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | |
|
| 211 |
-| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | |
|
| 212 |
-| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | |
|
| 213 |
-| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | |
|
| 214 |
-| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) | |
|
| 215 |
-| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | |
|
| 216 |
-| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | |
|
| 217 |
-| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | |
|
| 218 |
-| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar | |
|
| 219 |
-| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | |
|
| 220 |
-| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | |
|
| 221 |
-| [Influxus] (http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB] (http://influxdata.com/) | |
|
| 222 |
-| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | |
|
| 223 |
-| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | |
|
| 224 |
-| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | |
|
| 225 |
-| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) | |
|
| 226 |
-| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) | |
|
| 227 |
-| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka | |
|
| 228 |
-| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | |
|
| 229 |
-| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch| |
|
| 230 |
-| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| |
|
| 231 |
-| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)| |
|
| 232 |
-| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) | |
|
| 233 |
-| [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 | |
|
| 234 |
-| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) | |
|
| 235 |
-| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) | |
|
| 236 |
- |
|
| 237 |
- |
|
| 238 |
-#### Level logging |
|
| 239 |
- |
|
| 240 |
-Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic. |
|
| 241 |
- |
|
| 242 |
-```go |
|
| 243 |
-log.Debug("Useful debugging information.")
|
|
| 244 |
-log.Info("Something noteworthy happened!")
|
|
| 245 |
-log.Warn("You should probably take a look at this.")
|
|
| 246 |
-log.Error("Something failed but I'm not quitting.")
|
|
| 247 |
-// Calls os.Exit(1) after logging |
|
| 248 |
-log.Fatal("Bye.")
|
|
| 249 |
-// Calls panic() after logging |
|
| 250 |
-log.Panic("I'm bailing.")
|
|
| 251 |
-``` |
|
| 252 |
- |
|
| 253 |
-You can set the logging level on a `Logger`, then it will only log entries with |
|
| 254 |
-that severity or anything above it: |
|
| 255 |
- |
|
| 256 |
-```go |
|
| 257 |
-// Will log anything that is info or above (warn, error, fatal, panic). Default. |
|
| 258 |
-log.SetLevel(log.InfoLevel) |
|
| 259 |
-``` |
|
| 260 |
- |
|
| 261 |
-It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose |
|
| 262 |
-environment if your application has that. |
|
| 263 |
- |
|
| 264 |
-#### Entries |
|
| 265 |
- |
|
| 266 |
-Besides the fields added with `WithField` or `WithFields` some fields are |
|
| 267 |
-automatically added to all logging events: |
|
| 268 |
- |
|
| 269 |
-1. `time`. The timestamp when the entry was created. |
|
| 270 |
-2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
|
|
| 271 |
- the `AddFields` call. E.g. `Failed to send event.` |
|
| 272 |
-3. `level`. The logging level. E.g. `info`. |
|
| 273 |
- |
|
| 274 |
-#### Environments |
|
| 275 |
- |
|
| 276 |
-Logrus has no notion of environment. |
|
| 277 |
- |
|
| 278 |
-If you wish for hooks and formatters to only be used in specific environments, |
|
| 279 |
-you should handle that yourself. For example, if your application has a global |
|
| 280 |
-variable `Environment`, which is a string representation of the environment you |
|
| 281 |
-could do: |
|
| 282 |
- |
|
| 283 |
-```go |
|
| 284 |
-import ( |
|
| 285 |
- log "github.com/Sirupsen/logrus" |
|
| 286 |
-) |
|
| 287 |
- |
|
| 288 |
-init() {
|
|
| 289 |
- // do something here to set environment depending on an environment variable |
|
| 290 |
- // or command-line flag |
|
| 291 |
- if Environment == "production" {
|
|
| 292 |
- log.SetFormatter(&log.JSONFormatter{})
|
|
| 293 |
- } else {
|
|
| 294 |
- // The TextFormatter is default, you don't actually have to do this. |
|
| 295 |
- log.SetFormatter(&log.TextFormatter{})
|
|
| 296 |
- } |
|
| 297 |
-} |
|
| 298 |
-``` |
|
| 299 |
- |
|
| 300 |
-This configuration is how `logrus` was intended to be used, but JSON in |
|
| 301 |
-production is mostly only useful if you do log aggregation with tools like |
|
| 302 |
-Splunk or Logstash. |
|
| 303 |
- |
|
| 304 |
-#### Formatters |
|
| 305 |
- |
|
| 306 |
-The built-in logging formatters are: |
|
| 307 |
- |
|
| 308 |
-* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise |
|
| 309 |
- without colors. |
|
| 310 |
- * *Note:* to force colored output when there is no TTY, set the `ForceColors` |
|
| 311 |
- field to `true`. To force no colored output even if there is a TTY set the |
|
| 312 |
- `DisableColors` field to `true` |
|
| 313 |
-* `logrus.JSONFormatter`. Logs fields as JSON. |
|
| 314 |
- |
|
| 315 |
-Third party logging formatters: |
|
| 316 |
- |
|
| 317 |
-* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. |
|
| 318 |
-* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. |
|
| 319 |
-* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. |
|
| 320 |
- |
|
| 321 |
-You can define your formatter by implementing the `Formatter` interface, |
|
| 322 |
-requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a |
|
| 323 |
-`Fields` type (`map[string]interface{}`) with all your fields as well as the
|
|
| 324 |
-default ones (see Entries section above): |
|
| 325 |
- |
|
| 326 |
-```go |
|
| 327 |
-type MyJSONFormatter struct {
|
|
| 328 |
-} |
|
| 329 |
- |
|
| 330 |
-log.SetFormatter(new(MyJSONFormatter)) |
|
| 331 |
- |
|
| 332 |
-func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
|
|
| 333 |
- // Note this doesn't include Time, Level and Message which are available on |
|
| 334 |
- // the Entry. Consult `godoc` on information about those fields or read the |
|
| 335 |
- // source of the official loggers. |
|
| 336 |
- serialized, err := json.Marshal(entry.Data) |
|
| 337 |
- if err != nil {
|
|
| 338 |
- return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
|
| 339 |
- } |
|
| 340 |
- return append(serialized, '\n'), nil |
|
| 341 |
-} |
|
| 342 |
-``` |
|
| 343 |
- |
|
| 344 |
-#### Logger as an `io.Writer` |
|
| 345 |
- |
|
| 346 |
-Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it. |
|
| 347 |
- |
|
| 348 |
-```go |
|
| 349 |
-w := logger.Writer() |
|
| 350 |
-defer w.Close() |
|
| 351 |
- |
|
| 352 |
-srv := http.Server{
|
|
| 353 |
- // create a stdlib log.Logger that writes to |
|
| 354 |
- // logrus.Logger. |
|
| 355 |
- ErrorLog: log.New(w, "", 0), |
|
| 356 |
-} |
|
| 357 |
-``` |
|
| 358 |
- |
|
| 359 |
-Each line written to that writer will be printed the usual way, using formatters |
|
| 360 |
-and hooks. The level for those entries is `info`. |
|
| 361 |
- |
|
| 362 |
-#### Rotation |
|
| 363 |
- |
|
| 364 |
-Log rotation is not provided with Logrus. Log rotation should be done by an |
|
| 365 |
-external program (like `logrotate(8)`) that can compress and delete old log |
|
| 366 |
-entries. It should not be a feature of the application-level logger. |
|
| 367 |
- |
|
| 368 |
-#### Tools |
|
| 369 |
- |
|
| 370 |
-| Tool | Description | |
|
| 371 |
-| ---- | ----------- | |
|
| 372 |
-|[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.| |
|
| 373 |
-|[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) | |
|
| 374 |
- |
|
| 375 |
-#### Testing |
|
| 376 |
- |
|
| 377 |
-Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides: |
|
| 378 |
- |
|
| 379 |
-* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just add the `test` hook |
|
| 380 |
-* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any): |
|
| 381 |
- |
|
| 382 |
-```go |
|
| 383 |
-logger, hook := NewNullLogger() |
|
| 384 |
-logger.Error("Hello error")
|
|
| 385 |
- |
|
| 386 |
-assert.Equal(1, len(hook.Entries)) |
|
| 387 |
-assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level) |
|
| 388 |
-assert.Equal("Hello error", hook.LastEntry().Message)
|
|
| 389 |
- |
|
| 390 |
-hook.Reset() |
|
| 391 |
-assert.Nil(hook.LastEntry()) |
|
| 392 |
-``` |
|
| 393 |
- |
|
| 394 |
-#### Fatal handlers |
|
| 395 |
- |
|
| 396 |
-Logrus can register one or more functions that will be called when any `fatal` |
|
| 397 |
-level message is logged. The registered handlers will be executed before |
|
| 398 |
-logrus performs a `os.Exit(1)`. This behavior may be helpful if callers need |
|
| 399 |
-to gracefully shutdown. Unlike a `panic("Something went wrong...")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted.
|
|
| 400 |
- |
|
| 401 |
-``` |
|
| 402 |
-... |
|
| 403 |
-handler := func() {
|
|
| 404 |
- // gracefully shutdown something... |
|
| 405 |
-} |
|
| 406 |
-logrus.RegisterExitHandler(handler) |
|
| 407 |
-... |
|
| 408 |
-``` |
|
| 409 |
- |
|
| 410 |
-#### Thread safty |
|
| 411 |
- |
|
| 412 |
-By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs. |
|
| 413 |
-If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking. |
|
| 414 |
- |
|
| 415 |
-Situation when locking is not needed includes: |
|
| 416 |
- |
|
| 417 |
-* You have no hooks registered, or hooks calling is already thread-safe. |
|
| 418 |
- |
|
| 419 |
-* Writing to logger.Out is already thread-safe, for example: |
|
| 420 |
- |
|
| 421 |
- 1) logger.Out is protected by locks. |
|
| 422 |
- |
|
| 423 |
- 2) logger.Out is a os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allow multi-thread/multi-process writing) |
|
| 424 |
- |
|
| 425 |
- (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/) |
| 426 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,64 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-// The following code was sourced and modified from the |
|
| 4 |
-// https://bitbucket.org/tebeka/atexit package governed by the following license: |
|
| 5 |
-// |
|
| 6 |
-// Copyright (c) 2012 Miki Tebeka <miki.tebeka@gmail.com>. |
|
| 7 |
-// |
|
| 8 |
-// Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
| 9 |
-// this software and associated documentation files (the "Software"), to deal in |
|
| 10 |
-// the Software without restriction, including without limitation the rights to |
|
| 11 |
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
| 12 |
-// the Software, and to permit persons to whom the Software is furnished to do so, |
|
| 13 |
-// subject to the following conditions: |
|
| 14 |
-// |
|
| 15 |
-// The above copyright notice and this permission notice shall be included in all |
|
| 16 |
-// copies or substantial portions of the Software. |
|
| 17 |
-// |
|
| 18 |
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 19 |
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
| 20 |
-// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
| 21 |
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
| 22 |
-// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
| 23 |
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
| 24 |
- |
|
| 25 |
-import ( |
|
| 26 |
- "fmt" |
|
| 27 |
- "os" |
|
| 28 |
-) |
|
| 29 |
- |
|
| 30 |
-var handlers = []func(){}
|
|
| 31 |
- |
|
| 32 |
-func runHandler(handler func()) {
|
|
| 33 |
- defer func() {
|
|
| 34 |
- if err := recover(); err != nil {
|
|
| 35 |
- fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) |
|
| 36 |
- } |
|
| 37 |
- }() |
|
| 38 |
- |
|
| 39 |
- handler() |
|
| 40 |
-} |
|
| 41 |
- |
|
| 42 |
-func runHandlers() {
|
|
| 43 |
- for _, handler := range handlers {
|
|
| 44 |
- runHandler(handler) |
|
| 45 |
- } |
|
| 46 |
-} |
|
| 47 |
- |
|
| 48 |
-// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) |
|
| 49 |
-func Exit(code int) {
|
|
| 50 |
- runHandlers() |
|
| 51 |
- os.Exit(code) |
|
| 52 |
-} |
|
| 53 |
- |
|
| 54 |
-// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke |
|
| 55 |
-// all handlers. The handlers will also be invoked when any Fatal log entry is |
|
| 56 |
-// made. |
|
| 57 |
-// |
|
| 58 |
-// This method is useful when a caller wishes to use logrus to log a fatal |
|
| 59 |
-// message but also needs to gracefully shutdown. An example usecase could be |
|
| 60 |
-// closing database connections, or sending a alert that the application is |
|
| 61 |
-// closing. |
|
| 62 |
-func RegisterExitHandler(handler func()) {
|
|
| 63 |
- handlers = append(handlers, handler) |
|
| 64 |
-} |
| 65 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,26 +0,0 @@ |
| 1 |
-/* |
|
| 2 |
-Package logrus is a structured logger for Go, completely API compatible with the standard library logger. |
|
| 3 |
- |
|
| 4 |
- |
|
| 5 |
-The simplest way to use Logrus is simply the package-level exported logger: |
|
| 6 |
- |
|
| 7 |
- package main |
|
| 8 |
- |
|
| 9 |
- import ( |
|
| 10 |
- log "github.com/Sirupsen/logrus" |
|
| 11 |
- ) |
|
| 12 |
- |
|
| 13 |
- func main() {
|
|
| 14 |
- log.WithFields(log.Fields{
|
|
| 15 |
- "animal": "walrus", |
|
| 16 |
- "number": 1, |
|
| 17 |
- "size": 10, |
|
| 18 |
- }).Info("A walrus appears")
|
|
| 19 |
- } |
|
| 20 |
- |
|
| 21 |
-Output: |
|
| 22 |
- time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 |
|
| 23 |
- |
|
| 24 |
-For a full guide visit https://github.com/Sirupsen/logrus |
|
| 25 |
-*/ |
|
| 26 |
-package logrus |
| 27 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,275 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "bytes" |
|
| 5 |
- "fmt" |
|
| 6 |
- "os" |
|
| 7 |
- "sync" |
|
| 8 |
- "time" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-var bufferPool *sync.Pool |
|
| 12 |
- |
|
| 13 |
-func init() {
|
|
| 14 |
- bufferPool = &sync.Pool{
|
|
| 15 |
- New: func() interface{} {
|
|
| 16 |
- return new(bytes.Buffer) |
|
| 17 |
- }, |
|
| 18 |
- } |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-// Defines the key when adding errors using WithError. |
|
| 22 |
-var ErrorKey = "error" |
|
| 23 |
- |
|
| 24 |
-// An entry is the final or intermediate Logrus logging entry. It contains all |
|
| 25 |
-// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
|
|
| 26 |
-// Warn, Error, Fatal or Panic is called on it. These objects can be reused and |
|
| 27 |
-// passed around as much as you wish to avoid field duplication. |
|
| 28 |
-type Entry struct {
|
|
| 29 |
- Logger *Logger |
|
| 30 |
- |
|
| 31 |
- // Contains all the fields set by the user. |
|
| 32 |
- Data Fields |
|
| 33 |
- |
|
| 34 |
- // Time at which the log entry was created |
|
| 35 |
- Time time.Time |
|
| 36 |
- |
|
| 37 |
- // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic |
|
| 38 |
- Level Level |
|
| 39 |
- |
|
| 40 |
- // Message passed to Debug, Info, Warn, Error, Fatal or Panic |
|
| 41 |
- Message string |
|
| 42 |
- |
|
| 43 |
- // When formatter is called in entry.log(), an Buffer may be set to entry |
|
| 44 |
- Buffer *bytes.Buffer |
|
| 45 |
-} |
|
| 46 |
- |
|
| 47 |
-func NewEntry(logger *Logger) *Entry {
|
|
| 48 |
- return &Entry{
|
|
| 49 |
- Logger: logger, |
|
| 50 |
- // Default is three fields, give a little extra room |
|
| 51 |
- Data: make(Fields, 5), |
|
| 52 |
- } |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 |
-// Returns the string representation from the reader and ultimately the |
|
| 56 |
-// formatter. |
|
| 57 |
-func (entry *Entry) String() (string, error) {
|
|
| 58 |
- serialized, err := entry.Logger.Formatter.Format(entry) |
|
| 59 |
- if err != nil {
|
|
| 60 |
- return "", err |
|
| 61 |
- } |
|
| 62 |
- str := string(serialized) |
|
| 63 |
- return str, nil |
|
| 64 |
-} |
|
| 65 |
- |
|
| 66 |
-// Add an error as single field (using the key defined in ErrorKey) to the Entry. |
|
| 67 |
-func (entry *Entry) WithError(err error) *Entry {
|
|
| 68 |
- return entry.WithField(ErrorKey, err) |
|
| 69 |
-} |
|
| 70 |
- |
|
| 71 |
-// Add a single field to the Entry. |
|
| 72 |
-func (entry *Entry) WithField(key string, value interface{}) *Entry {
|
|
| 73 |
- return entry.WithFields(Fields{key: value})
|
|
| 74 |
-} |
|
| 75 |
- |
|
| 76 |
-// Add a map of fields to the Entry. |
|
| 77 |
-func (entry *Entry) WithFields(fields Fields) *Entry {
|
|
| 78 |
- data := make(Fields, len(entry.Data)+len(fields)) |
|
| 79 |
- for k, v := range entry.Data {
|
|
| 80 |
- data[k] = v |
|
| 81 |
- } |
|
| 82 |
- for k, v := range fields {
|
|
| 83 |
- data[k] = v |
|
| 84 |
- } |
|
| 85 |
- return &Entry{Logger: entry.Logger, Data: data}
|
|
| 86 |
-} |
|
| 87 |
- |
|
| 88 |
-// This function is not declared with a pointer value because otherwise |
|
| 89 |
-// race conditions will occur when using multiple goroutines |
|
| 90 |
-func (entry Entry) log(level Level, msg string) {
|
|
| 91 |
- var buffer *bytes.Buffer |
|
| 92 |
- entry.Time = time.Now() |
|
| 93 |
- entry.Level = level |
|
| 94 |
- entry.Message = msg |
|
| 95 |
- |
|
| 96 |
- if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
|
|
| 97 |
- entry.Logger.mu.Lock() |
|
| 98 |
- fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) |
|
| 99 |
- entry.Logger.mu.Unlock() |
|
| 100 |
- } |
|
| 101 |
- buffer = bufferPool.Get().(*bytes.Buffer) |
|
| 102 |
- buffer.Reset() |
|
| 103 |
- defer bufferPool.Put(buffer) |
|
| 104 |
- entry.Buffer = buffer |
|
| 105 |
- serialized, err := entry.Logger.Formatter.Format(&entry) |
|
| 106 |
- entry.Buffer = nil |
|
| 107 |
- if err != nil {
|
|
| 108 |
- entry.Logger.mu.Lock() |
|
| 109 |
- fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err) |
|
| 110 |
- entry.Logger.mu.Unlock() |
|
| 111 |
- } else {
|
|
| 112 |
- entry.Logger.mu.Lock() |
|
| 113 |
- _, err = entry.Logger.Out.Write(serialized) |
|
| 114 |
- if err != nil {
|
|
| 115 |
- fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) |
|
| 116 |
- } |
|
| 117 |
- entry.Logger.mu.Unlock() |
|
| 118 |
- } |
|
| 119 |
- |
|
| 120 |
- // To avoid Entry#log() returning a value that only would make sense for |
|
| 121 |
- // panic() to use in Entry#Panic(), we avoid the allocation by checking |
|
| 122 |
- // directly here. |
|
| 123 |
- if level <= PanicLevel {
|
|
| 124 |
- panic(&entry) |
|
| 125 |
- } |
|
| 126 |
-} |
|
| 127 |
- |
|
| 128 |
-func (entry *Entry) Debug(args ...interface{}) {
|
|
| 129 |
- if entry.Logger.Level >= DebugLevel {
|
|
| 130 |
- entry.log(DebugLevel, fmt.Sprint(args...)) |
|
| 131 |
- } |
|
| 132 |
-} |
|
| 133 |
- |
|
| 134 |
-func (entry *Entry) Print(args ...interface{}) {
|
|
| 135 |
- entry.Info(args...) |
|
| 136 |
-} |
|
| 137 |
- |
|
| 138 |
-func (entry *Entry) Info(args ...interface{}) {
|
|
| 139 |
- if entry.Logger.Level >= InfoLevel {
|
|
| 140 |
- entry.log(InfoLevel, fmt.Sprint(args...)) |
|
| 141 |
- } |
|
| 142 |
-} |
|
| 143 |
- |
|
| 144 |
-func (entry *Entry) Warn(args ...interface{}) {
|
|
| 145 |
- if entry.Logger.Level >= WarnLevel {
|
|
| 146 |
- entry.log(WarnLevel, fmt.Sprint(args...)) |
|
| 147 |
- } |
|
| 148 |
-} |
|
| 149 |
- |
|
| 150 |
-func (entry *Entry) Warning(args ...interface{}) {
|
|
| 151 |
- entry.Warn(args...) |
|
| 152 |
-} |
|
| 153 |
- |
|
| 154 |
-func (entry *Entry) Error(args ...interface{}) {
|
|
| 155 |
- if entry.Logger.Level >= ErrorLevel {
|
|
| 156 |
- entry.log(ErrorLevel, fmt.Sprint(args...)) |
|
| 157 |
- } |
|
| 158 |
-} |
|
| 159 |
- |
|
| 160 |
-func (entry *Entry) Fatal(args ...interface{}) {
|
|
| 161 |
- if entry.Logger.Level >= FatalLevel {
|
|
| 162 |
- entry.log(FatalLevel, fmt.Sprint(args...)) |
|
| 163 |
- } |
|
| 164 |
- Exit(1) |
|
| 165 |
-} |
|
| 166 |
- |
|
| 167 |
-func (entry *Entry) Panic(args ...interface{}) {
|
|
| 168 |
- if entry.Logger.Level >= PanicLevel {
|
|
| 169 |
- entry.log(PanicLevel, fmt.Sprint(args...)) |
|
| 170 |
- } |
|
| 171 |
- panic(fmt.Sprint(args...)) |
|
| 172 |
-} |
|
| 173 |
- |
|
| 174 |
-// Entry Printf family functions |
|
| 175 |
- |
|
| 176 |
-func (entry *Entry) Debugf(format string, args ...interface{}) {
|
|
| 177 |
- if entry.Logger.Level >= DebugLevel {
|
|
| 178 |
- entry.Debug(fmt.Sprintf(format, args...)) |
|
| 179 |
- } |
|
| 180 |
-} |
|
| 181 |
- |
|
| 182 |
-func (entry *Entry) Infof(format string, args ...interface{}) {
|
|
| 183 |
- if entry.Logger.Level >= InfoLevel {
|
|
| 184 |
- entry.Info(fmt.Sprintf(format, args...)) |
|
| 185 |
- } |
|
| 186 |
-} |
|
| 187 |
- |
|
| 188 |
-func (entry *Entry) Printf(format string, args ...interface{}) {
|
|
| 189 |
- entry.Infof(format, args...) |
|
| 190 |
-} |
|
| 191 |
- |
|
| 192 |
-func (entry *Entry) Warnf(format string, args ...interface{}) {
|
|
| 193 |
- if entry.Logger.Level >= WarnLevel {
|
|
| 194 |
- entry.Warn(fmt.Sprintf(format, args...)) |
|
| 195 |
- } |
|
| 196 |
-} |
|
| 197 |
- |
|
| 198 |
-func (entry *Entry) Warningf(format string, args ...interface{}) {
|
|
| 199 |
- entry.Warnf(format, args...) |
|
| 200 |
-} |
|
| 201 |
- |
|
| 202 |
-func (entry *Entry) Errorf(format string, args ...interface{}) {
|
|
| 203 |
- if entry.Logger.Level >= ErrorLevel {
|
|
| 204 |
- entry.Error(fmt.Sprintf(format, args...)) |
|
| 205 |
- } |
|
| 206 |
-} |
|
| 207 |
- |
|
| 208 |
-func (entry *Entry) Fatalf(format string, args ...interface{}) {
|
|
| 209 |
- if entry.Logger.Level >= FatalLevel {
|
|
| 210 |
- entry.Fatal(fmt.Sprintf(format, args...)) |
|
| 211 |
- } |
|
| 212 |
- Exit(1) |
|
| 213 |
-} |
|
| 214 |
- |
|
| 215 |
-func (entry *Entry) Panicf(format string, args ...interface{}) {
|
|
| 216 |
- if entry.Logger.Level >= PanicLevel {
|
|
| 217 |
- entry.Panic(fmt.Sprintf(format, args...)) |
|
| 218 |
- } |
|
| 219 |
-} |
|
| 220 |
- |
|
| 221 |
-// Entry Println family functions |
|
| 222 |
- |
|
| 223 |
-func (entry *Entry) Debugln(args ...interface{}) {
|
|
| 224 |
- if entry.Logger.Level >= DebugLevel {
|
|
| 225 |
- entry.Debug(entry.sprintlnn(args...)) |
|
| 226 |
- } |
|
| 227 |
-} |
|
| 228 |
- |
|
| 229 |
-func (entry *Entry) Infoln(args ...interface{}) {
|
|
| 230 |
- if entry.Logger.Level >= InfoLevel {
|
|
| 231 |
- entry.Info(entry.sprintlnn(args...)) |
|
| 232 |
- } |
|
| 233 |
-} |
|
| 234 |
- |
|
| 235 |
-func (entry *Entry) Println(args ...interface{}) {
|
|
| 236 |
- entry.Infoln(args...) |
|
| 237 |
-} |
|
| 238 |
- |
|
| 239 |
-func (entry *Entry) Warnln(args ...interface{}) {
|
|
| 240 |
- if entry.Logger.Level >= WarnLevel {
|
|
| 241 |
- entry.Warn(entry.sprintlnn(args...)) |
|
| 242 |
- } |
|
| 243 |
-} |
|
| 244 |
- |
|
| 245 |
-func (entry *Entry) Warningln(args ...interface{}) {
|
|
| 246 |
- entry.Warnln(args...) |
|
| 247 |
-} |
|
| 248 |
- |
|
| 249 |
-func (entry *Entry) Errorln(args ...interface{}) {
|
|
| 250 |
- if entry.Logger.Level >= ErrorLevel {
|
|
| 251 |
- entry.Error(entry.sprintlnn(args...)) |
|
| 252 |
- } |
|
| 253 |
-} |
|
| 254 |
- |
|
| 255 |
-func (entry *Entry) Fatalln(args ...interface{}) {
|
|
| 256 |
- if entry.Logger.Level >= FatalLevel {
|
|
| 257 |
- entry.Fatal(entry.sprintlnn(args...)) |
|
| 258 |
- } |
|
| 259 |
- Exit(1) |
|
| 260 |
-} |
|
| 261 |
- |
|
| 262 |
-func (entry *Entry) Panicln(args ...interface{}) {
|
|
| 263 |
- if entry.Logger.Level >= PanicLevel {
|
|
| 264 |
- entry.Panic(entry.sprintlnn(args...)) |
|
| 265 |
- } |
|
| 266 |
-} |
|
| 267 |
- |
|
| 268 |
-// Sprintlnn => Sprint no newline. This is to get the behavior of how |
|
| 269 |
-// fmt.Sprintln where spaces are always added between operands, regardless of |
|
| 270 |
-// their type. Instead of vendoring the Sprintln implementation to spare a |
|
| 271 |
-// string allocation, we do the simplest thing. |
|
| 272 |
-func (entry *Entry) sprintlnn(args ...interface{}) string {
|
|
| 273 |
- msg := fmt.Sprintln(args...) |
|
| 274 |
- return msg[:len(msg)-1] |
|
| 275 |
-} |
| 276 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,193 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "io" |
|
| 5 |
-) |
|
| 6 |
- |
|
| 7 |
-var ( |
|
| 8 |
- // std is the name of the standard logger in stdlib `log` |
|
| 9 |
- std = New() |
|
| 10 |
-) |
|
| 11 |
- |
|
| 12 |
-func StandardLogger() *Logger {
|
|
| 13 |
- return std |
|
| 14 |
-} |
|
| 15 |
- |
|
| 16 |
-// SetOutput sets the standard logger output. |
|
| 17 |
-func SetOutput(out io.Writer) {
|
|
| 18 |
- std.mu.Lock() |
|
| 19 |
- defer std.mu.Unlock() |
|
| 20 |
- std.Out = out |
|
| 21 |
-} |
|
| 22 |
- |
|
| 23 |
-// SetFormatter sets the standard logger formatter. |
|
| 24 |
-func SetFormatter(formatter Formatter) {
|
|
| 25 |
- std.mu.Lock() |
|
| 26 |
- defer std.mu.Unlock() |
|
| 27 |
- std.Formatter = formatter |
|
| 28 |
-} |
|
| 29 |
- |
|
| 30 |
-// SetLevel sets the standard logger level. |
|
| 31 |
-func SetLevel(level Level) {
|
|
| 32 |
- std.mu.Lock() |
|
| 33 |
- defer std.mu.Unlock() |
|
| 34 |
- std.Level = level |
|
| 35 |
-} |
|
| 36 |
- |
|
| 37 |
-// GetLevel returns the standard logger level. |
|
| 38 |
-func GetLevel() Level {
|
|
| 39 |
- std.mu.Lock() |
|
| 40 |
- defer std.mu.Unlock() |
|
| 41 |
- return std.Level |
|
| 42 |
-} |
|
| 43 |
- |
|
| 44 |
-// AddHook adds a hook to the standard logger hooks. |
|
| 45 |
-func AddHook(hook Hook) {
|
|
| 46 |
- std.mu.Lock() |
|
| 47 |
- defer std.mu.Unlock() |
|
| 48 |
- std.Hooks.Add(hook) |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. |
|
| 52 |
-func WithError(err error) *Entry {
|
|
| 53 |
- return std.WithField(ErrorKey, err) |
|
| 54 |
-} |
|
| 55 |
- |
|
| 56 |
-// WithField creates an entry from the standard logger and adds a field to |
|
| 57 |
-// it. If you want multiple fields, use `WithFields`. |
|
| 58 |
-// |
|
| 59 |
-// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal |
|
| 60 |
-// or Panic on the Entry it returns. |
|
| 61 |
-func WithField(key string, value interface{}) *Entry {
|
|
| 62 |
- return std.WithField(key, value) |
|
| 63 |
-} |
|
| 64 |
- |
|
| 65 |
-// WithFields creates an entry from the standard logger and adds multiple |
|
| 66 |
-// fields to it. This is simply a helper for `WithField`, invoking it |
|
| 67 |
-// once for each field. |
|
| 68 |
-// |
|
| 69 |
-// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal |
|
| 70 |
-// or Panic on the Entry it returns. |
|
| 71 |
-func WithFields(fields Fields) *Entry {
|
|
| 72 |
- return std.WithFields(fields) |
|
| 73 |
-} |
|
| 74 |
- |
|
| 75 |
-// Debug logs a message at level Debug on the standard logger. |
|
| 76 |
-func Debug(args ...interface{}) {
|
|
| 77 |
- std.Debug(args...) |
|
| 78 |
-} |
|
| 79 |
- |
|
| 80 |
-// Print logs a message at level Info on the standard logger. |
|
| 81 |
-func Print(args ...interface{}) {
|
|
| 82 |
- std.Print(args...) |
|
| 83 |
-} |
|
| 84 |
- |
|
| 85 |
-// Info logs a message at level Info on the standard logger. |
|
| 86 |
-func Info(args ...interface{}) {
|
|
| 87 |
- std.Info(args...) |
|
| 88 |
-} |
|
| 89 |
- |
|
| 90 |
-// Warn logs a message at level Warn on the standard logger. |
|
| 91 |
-func Warn(args ...interface{}) {
|
|
| 92 |
- std.Warn(args...) |
|
| 93 |
-} |
|
| 94 |
- |
|
| 95 |
-// Warning logs a message at level Warn on the standard logger. |
|
| 96 |
-func Warning(args ...interface{}) {
|
|
| 97 |
- std.Warning(args...) |
|
| 98 |
-} |
|
| 99 |
- |
|
| 100 |
-// Error logs a message at level Error on the standard logger. |
|
| 101 |
-func Error(args ...interface{}) {
|
|
| 102 |
- std.Error(args...) |
|
| 103 |
-} |
|
| 104 |
- |
|
| 105 |
-// Panic logs a message at level Panic on the standard logger. |
|
| 106 |
-func Panic(args ...interface{}) {
|
|
| 107 |
- std.Panic(args...) |
|
| 108 |
-} |
|
| 109 |
- |
|
| 110 |
-// Fatal logs a message at level Fatal on the standard logger. |
|
| 111 |
-func Fatal(args ...interface{}) {
|
|
| 112 |
- std.Fatal(args...) |
|
| 113 |
-} |
|
| 114 |
- |
|
| 115 |
-// Debugf logs a message at level Debug on the standard logger. |
|
| 116 |
-func Debugf(format string, args ...interface{}) {
|
|
| 117 |
- std.Debugf(format, args...) |
|
| 118 |
-} |
|
| 119 |
- |
|
| 120 |
-// Printf logs a message at level Info on the standard logger. |
|
| 121 |
-func Printf(format string, args ...interface{}) {
|
|
| 122 |
- std.Printf(format, args...) |
|
| 123 |
-} |
|
| 124 |
- |
|
| 125 |
-// Infof logs a message at level Info on the standard logger. |
|
| 126 |
-func Infof(format string, args ...interface{}) {
|
|
| 127 |
- std.Infof(format, args...) |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-// Warnf logs a message at level Warn on the standard logger. |
|
| 131 |
-func Warnf(format string, args ...interface{}) {
|
|
| 132 |
- std.Warnf(format, args...) |
|
| 133 |
-} |
|
| 134 |
- |
|
| 135 |
-// Warningf logs a message at level Warn on the standard logger. |
|
| 136 |
-func Warningf(format string, args ...interface{}) {
|
|
| 137 |
- std.Warningf(format, args...) |
|
| 138 |
-} |
|
| 139 |
- |
|
| 140 |
-// Errorf logs a message at level Error on the standard logger. |
|
| 141 |
-func Errorf(format string, args ...interface{}) {
|
|
| 142 |
- std.Errorf(format, args...) |
|
| 143 |
-} |
|
| 144 |
- |
|
| 145 |
-// Panicf logs a message at level Panic on the standard logger. |
|
| 146 |
-func Panicf(format string, args ...interface{}) {
|
|
| 147 |
- std.Panicf(format, args...) |
|
| 148 |
-} |
|
| 149 |
- |
|
| 150 |
-// Fatalf logs a message at level Fatal on the standard logger. |
|
| 151 |
-func Fatalf(format string, args ...interface{}) {
|
|
| 152 |
- std.Fatalf(format, args...) |
|
| 153 |
-} |
|
| 154 |
- |
|
| 155 |
-// Debugln logs a message at level Debug on the standard logger. |
|
| 156 |
-func Debugln(args ...interface{}) {
|
|
| 157 |
- std.Debugln(args...) |
|
| 158 |
-} |
|
| 159 |
- |
|
| 160 |
-// Println logs a message at level Info on the standard logger. |
|
| 161 |
-func Println(args ...interface{}) {
|
|
| 162 |
- std.Println(args...) |
|
| 163 |
-} |
|
| 164 |
- |
|
| 165 |
-// Infoln logs a message at level Info on the standard logger. |
|
| 166 |
-func Infoln(args ...interface{}) {
|
|
| 167 |
- std.Infoln(args...) |
|
| 168 |
-} |
|
| 169 |
- |
|
| 170 |
-// Warnln logs a message at level Warn on the standard logger. |
|
| 171 |
-func Warnln(args ...interface{}) {
|
|
| 172 |
- std.Warnln(args...) |
|
| 173 |
-} |
|
| 174 |
- |
|
| 175 |
-// Warningln logs a message at level Warn on the standard logger. |
|
| 176 |
-func Warningln(args ...interface{}) {
|
|
| 177 |
- std.Warningln(args...) |
|
| 178 |
-} |
|
| 179 |
- |
|
| 180 |
-// Errorln logs a message at level Error on the standard logger. |
|
| 181 |
-func Errorln(args ...interface{}) {
|
|
| 182 |
- std.Errorln(args...) |
|
| 183 |
-} |
|
| 184 |
- |
|
| 185 |
-// Panicln logs a message at level Panic on the standard logger. |
|
| 186 |
-func Panicln(args ...interface{}) {
|
|
| 187 |
- std.Panicln(args...) |
|
| 188 |
-} |
|
| 189 |
- |
|
| 190 |
-// Fatalln logs a message at level Fatal on the standard logger. |
|
| 191 |
-func Fatalln(args ...interface{}) {
|
|
| 192 |
- std.Fatalln(args...) |
|
| 193 |
-} |
| 194 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,45 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import "time" |
|
| 4 |
- |
|
| 5 |
-const DefaultTimestampFormat = time.RFC3339 |
|
| 6 |
- |
|
| 7 |
-// The Formatter interface is used to implement a custom Formatter. It takes an |
|
| 8 |
-// `Entry`. It exposes all the fields, including the default ones: |
|
| 9 |
-// |
|
| 10 |
-// * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. |
|
| 11 |
-// * `entry.Data["time"]`. The timestamp. |
|
| 12 |
-// * `entry.Data["level"]. The level the entry was logged at. |
|
| 13 |
-// |
|
| 14 |
-// Any additional fields added with `WithField` or `WithFields` are also in |
|
| 15 |
-// `entry.Data`. Format is expected to return an array of bytes which are then |
|
| 16 |
-// logged to `logger.Out`. |
|
| 17 |
-type Formatter interface {
|
|
| 18 |
- Format(*Entry) ([]byte, error) |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-// This is to not silently overwrite `time`, `msg` and `level` fields when |
|
| 22 |
-// dumping it. If this code wasn't there doing: |
|
| 23 |
-// |
|
| 24 |
-// logrus.WithField("level", 1).Info("hello")
|
|
| 25 |
-// |
|
| 26 |
-// Would just silently drop the user provided level. Instead with this code |
|
| 27 |
-// it'll logged as: |
|
| 28 |
-// |
|
| 29 |
-// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
|
|
| 30 |
-// |
|
| 31 |
-// It's not exported because it's still using Data in an opinionated way. It's to |
|
| 32 |
-// avoid code duplication between the two default formatters. |
|
| 33 |
-func prefixFieldClashes(data Fields) {
|
|
| 34 |
- if t, ok := data["time"]; ok {
|
|
| 35 |
- data["fields.time"] = t |
|
| 36 |
- } |
|
| 37 |
- |
|
| 38 |
- if m, ok := data["msg"]; ok {
|
|
| 39 |
- data["fields.msg"] = m |
|
| 40 |
- } |
|
| 41 |
- |
|
| 42 |
- if l, ok := data["level"]; ok {
|
|
| 43 |
- data["fields.level"] = l |
|
| 44 |
- } |
|
| 45 |
-} |
| 46 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,34 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-// A hook to be fired when logging on the logging levels returned from |
|
| 4 |
-// `Levels()` on your implementation of the interface. Note that this is not |
|
| 5 |
-// fired in a goroutine or a channel with workers, you should handle such |
|
| 6 |
-// functionality yourself if your call is non-blocking and you don't wish for |
|
| 7 |
-// the logging calls for levels returned from `Levels()` to block. |
|
| 8 |
-type Hook interface {
|
|
| 9 |
- Levels() []Level |
|
| 10 |
- Fire(*Entry) error |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-// Internal type for storing the hooks on a logger instance. |
|
| 14 |
-type LevelHooks map[Level][]Hook |
|
| 15 |
- |
|
| 16 |
-// Add a hook to an instance of logger. This is called with |
|
| 17 |
-// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. |
|
| 18 |
-func (hooks LevelHooks) Add(hook Hook) {
|
|
| 19 |
- for _, level := range hook.Levels() {
|
|
| 20 |
- hooks[level] = append(hooks[level], hook) |
|
| 21 |
- } |
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 |
-// Fire all the hooks for the passed level. Used by `entry.log` to fire |
|
| 25 |
-// appropriate hooks for a log entry. |
|
| 26 |
-func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
|
|
| 27 |
- for _, hook := range hooks[level] {
|
|
| 28 |
- if err := hook.Fire(entry); err != nil {
|
|
| 29 |
- return err |
|
| 30 |
- } |
|
| 31 |
- } |
|
| 32 |
- |
|
| 33 |
- return nil |
|
| 34 |
-} |
| 35 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,41 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "encoding/json" |
|
| 5 |
- "fmt" |
|
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-type JSONFormatter struct {
|
|
| 9 |
- // TimestampFormat sets the format used for marshaling timestamps. |
|
| 10 |
- TimestampFormat string |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
|
|
| 14 |
- data := make(Fields, len(entry.Data)+3) |
|
| 15 |
- for k, v := range entry.Data {
|
|
| 16 |
- switch v := v.(type) {
|
|
| 17 |
- case error: |
|
| 18 |
- // Otherwise errors are ignored by `encoding/json` |
|
| 19 |
- // https://github.com/Sirupsen/logrus/issues/137 |
|
| 20 |
- data[k] = v.Error() |
|
| 21 |
- default: |
|
| 22 |
- data[k] = v |
|
| 23 |
- } |
|
| 24 |
- } |
|
| 25 |
- prefixFieldClashes(data) |
|
| 26 |
- |
|
| 27 |
- timestampFormat := f.TimestampFormat |
|
| 28 |
- if timestampFormat == "" {
|
|
| 29 |
- timestampFormat = DefaultTimestampFormat |
|
| 30 |
- } |
|
| 31 |
- |
|
| 32 |
- data["time"] = entry.Time.Format(timestampFormat) |
|
| 33 |
- data["msg"] = entry.Message |
|
| 34 |
- data["level"] = entry.Level.String() |
|
| 35 |
- |
|
| 36 |
- serialized, err := json.Marshal(data) |
|
| 37 |
- if err != nil {
|
|
| 38 |
- return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
|
| 39 |
- } |
|
| 40 |
- return append(serialized, '\n'), nil |
|
| 41 |
-} |
| 42 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,308 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "io" |
|
| 5 |
- "os" |
|
| 6 |
- "sync" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-type Logger struct {
|
|
| 10 |
- // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a |
|
| 11 |
- // file, or leave it default which is `os.Stderr`. You can also set this to |
|
| 12 |
- // something more adventorous, such as logging to Kafka. |
|
| 13 |
- Out io.Writer |
|
| 14 |
- // Hooks for the logger instance. These allow firing events based on logging |
|
| 15 |
- // levels and log entries. For example, to send errors to an error tracking |
|
| 16 |
- // service, log to StatsD or dump the core on fatal errors. |
|
| 17 |
- Hooks LevelHooks |
|
| 18 |
- // All log entries pass through the formatter before logged to Out. The |
|
| 19 |
- // included formatters are `TextFormatter` and `JSONFormatter` for which |
|
| 20 |
- // TextFormatter is the default. In development (when a TTY is attached) it |
|
| 21 |
- // logs with colors, but to a file it wouldn't. You can easily implement your |
|
| 22 |
- // own that implements the `Formatter` interface, see the `README` or included |
|
| 23 |
- // formatters for examples. |
|
| 24 |
- Formatter Formatter |
|
| 25 |
- // The logging level the logger should log at. This is typically (and defaults |
|
| 26 |
- // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be |
|
| 27 |
- // logged. `logrus.Debug` is useful in |
|
| 28 |
- Level Level |
|
| 29 |
- // Used to sync writing to the log. Locking is enabled by Default |
|
| 30 |
- mu MutexWrap |
|
| 31 |
- // Reusable empty entry |
|
| 32 |
- entryPool sync.Pool |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-type MutexWrap struct {
|
|
| 36 |
- lock sync.Mutex |
|
| 37 |
- disabled bool |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-func (mw *MutexWrap) Lock() {
|
|
| 41 |
- if !mw.disabled {
|
|
| 42 |
- mw.lock.Lock() |
|
| 43 |
- } |
|
| 44 |
-} |
|
| 45 |
- |
|
| 46 |
-func (mw *MutexWrap) Unlock() {
|
|
| 47 |
- if !mw.disabled {
|
|
| 48 |
- mw.lock.Unlock() |
|
| 49 |
- } |
|
| 50 |
-} |
|
| 51 |
- |
|
| 52 |
-func (mw *MutexWrap) Disable() {
|
|
| 53 |
- mw.disabled = true |
|
| 54 |
-} |
|
| 55 |
- |
|
| 56 |
-// Creates a new logger. Configuration should be set by changing `Formatter`, |
|
| 57 |
-// `Out` and `Hooks` directly on the default logger instance. You can also just |
|
| 58 |
-// instantiate your own: |
|
| 59 |
-// |
|
| 60 |
-// var log = &Logger{
|
|
| 61 |
-// Out: os.Stderr, |
|
| 62 |
-// Formatter: new(JSONFormatter), |
|
| 63 |
-// Hooks: make(LevelHooks), |
|
| 64 |
-// Level: logrus.DebugLevel, |
|
| 65 |
-// } |
|
| 66 |
-// |
|
| 67 |
-// It's recommended to make this a global instance called `log`. |
|
| 68 |
-func New() *Logger {
|
|
| 69 |
- return &Logger{
|
|
| 70 |
- Out: os.Stderr, |
|
| 71 |
- Formatter: new(TextFormatter), |
|
| 72 |
- Hooks: make(LevelHooks), |
|
| 73 |
- Level: InfoLevel, |
|
| 74 |
- } |
|
| 75 |
-} |
|
| 76 |
- |
|
| 77 |
-func (logger *Logger) newEntry() *Entry {
|
|
| 78 |
- entry, ok := logger.entryPool.Get().(*Entry) |
|
| 79 |
- if ok {
|
|
| 80 |
- return entry |
|
| 81 |
- } |
|
| 82 |
- return NewEntry(logger) |
|
| 83 |
-} |
|
| 84 |
- |
|
| 85 |
-func (logger *Logger) releaseEntry(entry *Entry) {
|
|
| 86 |
- logger.entryPool.Put(entry) |
|
| 87 |
-} |
|
| 88 |
- |
|
| 89 |
-// Adds a field to the log entry, note that it doesn't log until you call |
|
| 90 |
-// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. |
|
| 91 |
-// If you want multiple fields, use `WithFields`. |
|
| 92 |
-func (logger *Logger) WithField(key string, value interface{}) *Entry {
|
|
| 93 |
- entry := logger.newEntry() |
|
| 94 |
- defer logger.releaseEntry(entry) |
|
| 95 |
- return entry.WithField(key, value) |
|
| 96 |
-} |
|
| 97 |
- |
|
| 98 |
-// Adds a struct of fields to the log entry. All it does is call `WithField` for |
|
| 99 |
-// each `Field`. |
|
| 100 |
-func (logger *Logger) WithFields(fields Fields) *Entry {
|
|
| 101 |
- entry := logger.newEntry() |
|
| 102 |
- defer logger.releaseEntry(entry) |
|
| 103 |
- return entry.WithFields(fields) |
|
| 104 |
-} |
|
| 105 |
- |
|
| 106 |
-// Add an error as single field to the log entry. All it does is call |
|
| 107 |
-// `WithError` for the given `error`. |
|
| 108 |
-func (logger *Logger) WithError(err error) *Entry {
|
|
| 109 |
- entry := logger.newEntry() |
|
| 110 |
- defer logger.releaseEntry(entry) |
|
| 111 |
- return entry.WithError(err) |
|
| 112 |
-} |
|
| 113 |
- |
|
| 114 |
-func (logger *Logger) Debugf(format string, args ...interface{}) {
|
|
| 115 |
- if logger.Level >= DebugLevel {
|
|
| 116 |
- entry := logger.newEntry() |
|
| 117 |
- entry.Debugf(format, args...) |
|
| 118 |
- logger.releaseEntry(entry) |
|
| 119 |
- } |
|
| 120 |
-} |
|
| 121 |
- |
|
| 122 |
-func (logger *Logger) Infof(format string, args ...interface{}) {
|
|
| 123 |
- if logger.Level >= InfoLevel {
|
|
| 124 |
- entry := logger.newEntry() |
|
| 125 |
- entry.Infof(format, args...) |
|
| 126 |
- logger.releaseEntry(entry) |
|
| 127 |
- } |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-func (logger *Logger) Printf(format string, args ...interface{}) {
|
|
| 131 |
- entry := logger.newEntry() |
|
| 132 |
- entry.Printf(format, args...) |
|
| 133 |
- logger.releaseEntry(entry) |
|
| 134 |
-} |
|
| 135 |
- |
|
| 136 |
-func (logger *Logger) Warnf(format string, args ...interface{}) {
|
|
| 137 |
- if logger.Level >= WarnLevel {
|
|
| 138 |
- entry := logger.newEntry() |
|
| 139 |
- entry.Warnf(format, args...) |
|
| 140 |
- logger.releaseEntry(entry) |
|
| 141 |
- } |
|
| 142 |
-} |
|
| 143 |
- |
|
| 144 |
-func (logger *Logger) Warningf(format string, args ...interface{}) {
|
|
| 145 |
- if logger.Level >= WarnLevel {
|
|
| 146 |
- entry := logger.newEntry() |
|
| 147 |
- entry.Warnf(format, args...) |
|
| 148 |
- logger.releaseEntry(entry) |
|
| 149 |
- } |
|
| 150 |
-} |
|
| 151 |
- |
|
| 152 |
-func (logger *Logger) Errorf(format string, args ...interface{}) {
|
|
| 153 |
- if logger.Level >= ErrorLevel {
|
|
| 154 |
- entry := logger.newEntry() |
|
| 155 |
- entry.Errorf(format, args...) |
|
| 156 |
- logger.releaseEntry(entry) |
|
| 157 |
- } |
|
| 158 |
-} |
|
| 159 |
- |
|
| 160 |
-func (logger *Logger) Fatalf(format string, args ...interface{}) {
|
|
| 161 |
- if logger.Level >= FatalLevel {
|
|
| 162 |
- entry := logger.newEntry() |
|
| 163 |
- entry.Fatalf(format, args...) |
|
| 164 |
- logger.releaseEntry(entry) |
|
| 165 |
- } |
|
| 166 |
- Exit(1) |
|
| 167 |
-} |
|
| 168 |
- |
|
| 169 |
-func (logger *Logger) Panicf(format string, args ...interface{}) {
|
|
| 170 |
- if logger.Level >= PanicLevel {
|
|
| 171 |
- entry := logger.newEntry() |
|
| 172 |
- entry.Panicf(format, args...) |
|
| 173 |
- logger.releaseEntry(entry) |
|
| 174 |
- } |
|
| 175 |
-} |
|
| 176 |
- |
|
| 177 |
-func (logger *Logger) Debug(args ...interface{}) {
|
|
| 178 |
- if logger.Level >= DebugLevel {
|
|
| 179 |
- entry := logger.newEntry() |
|
| 180 |
- entry.Debug(args...) |
|
| 181 |
- logger.releaseEntry(entry) |
|
| 182 |
- } |
|
| 183 |
-} |
|
| 184 |
- |
|
| 185 |
-func (logger *Logger) Info(args ...interface{}) {
|
|
| 186 |
- if logger.Level >= InfoLevel {
|
|
| 187 |
- entry := logger.newEntry() |
|
| 188 |
- entry.Info(args...) |
|
| 189 |
- logger.releaseEntry(entry) |
|
| 190 |
- } |
|
| 191 |
-} |
|
| 192 |
- |
|
| 193 |
-func (logger *Logger) Print(args ...interface{}) {
|
|
| 194 |
- entry := logger.newEntry() |
|
| 195 |
- entry.Info(args...) |
|
| 196 |
- logger.releaseEntry(entry) |
|
| 197 |
-} |
|
| 198 |
- |
|
| 199 |
-func (logger *Logger) Warn(args ...interface{}) {
|
|
| 200 |
- if logger.Level >= WarnLevel {
|
|
| 201 |
- entry := logger.newEntry() |
|
| 202 |
- entry.Warn(args...) |
|
| 203 |
- logger.releaseEntry(entry) |
|
| 204 |
- } |
|
| 205 |
-} |
|
| 206 |
- |
|
| 207 |
-func (logger *Logger) Warning(args ...interface{}) {
|
|
| 208 |
- if logger.Level >= WarnLevel {
|
|
| 209 |
- entry := logger.newEntry() |
|
| 210 |
- entry.Warn(args...) |
|
| 211 |
- logger.releaseEntry(entry) |
|
| 212 |
- } |
|
| 213 |
-} |
|
| 214 |
- |
|
| 215 |
-func (logger *Logger) Error(args ...interface{}) {
|
|
| 216 |
- if logger.Level >= ErrorLevel {
|
|
| 217 |
- entry := logger.newEntry() |
|
| 218 |
- entry.Error(args...) |
|
| 219 |
- logger.releaseEntry(entry) |
|
| 220 |
- } |
|
| 221 |
-} |
|
| 222 |
- |
|
| 223 |
-func (logger *Logger) Fatal(args ...interface{}) {
|
|
| 224 |
- if logger.Level >= FatalLevel {
|
|
| 225 |
- entry := logger.newEntry() |
|
| 226 |
- entry.Fatal(args...) |
|
| 227 |
- logger.releaseEntry(entry) |
|
| 228 |
- } |
|
| 229 |
- Exit(1) |
|
| 230 |
-} |
|
| 231 |
- |
|
| 232 |
-func (logger *Logger) Panic(args ...interface{}) {
|
|
| 233 |
- if logger.Level >= PanicLevel {
|
|
| 234 |
- entry := logger.newEntry() |
|
| 235 |
- entry.Panic(args...) |
|
| 236 |
- logger.releaseEntry(entry) |
|
| 237 |
- } |
|
| 238 |
-} |
|
| 239 |
- |
|
| 240 |
-func (logger *Logger) Debugln(args ...interface{}) {
|
|
| 241 |
- if logger.Level >= DebugLevel {
|
|
| 242 |
- entry := logger.newEntry() |
|
| 243 |
- entry.Debugln(args...) |
|
| 244 |
- logger.releaseEntry(entry) |
|
| 245 |
- } |
|
| 246 |
-} |
|
| 247 |
- |
|
| 248 |
-func (logger *Logger) Infoln(args ...interface{}) {
|
|
| 249 |
- if logger.Level >= InfoLevel {
|
|
| 250 |
- entry := logger.newEntry() |
|
| 251 |
- entry.Infoln(args...) |
|
| 252 |
- logger.releaseEntry(entry) |
|
| 253 |
- } |
|
| 254 |
-} |
|
| 255 |
- |
|
| 256 |
-func (logger *Logger) Println(args ...interface{}) {
|
|
| 257 |
- entry := logger.newEntry() |
|
| 258 |
- entry.Println(args...) |
|
| 259 |
- logger.releaseEntry(entry) |
|
| 260 |
-} |
|
| 261 |
- |
|
| 262 |
-func (logger *Logger) Warnln(args ...interface{}) {
|
|
| 263 |
- if logger.Level >= WarnLevel {
|
|
| 264 |
- entry := logger.newEntry() |
|
| 265 |
- entry.Warnln(args...) |
|
| 266 |
- logger.releaseEntry(entry) |
|
| 267 |
- } |
|
| 268 |
-} |
|
| 269 |
- |
|
| 270 |
-func (logger *Logger) Warningln(args ...interface{}) {
|
|
| 271 |
- if logger.Level >= WarnLevel {
|
|
| 272 |
- entry := logger.newEntry() |
|
| 273 |
- entry.Warnln(args...) |
|
| 274 |
- logger.releaseEntry(entry) |
|
| 275 |
- } |
|
| 276 |
-} |
|
| 277 |
- |
|
| 278 |
-func (logger *Logger) Errorln(args ...interface{}) {
|
|
| 279 |
- if logger.Level >= ErrorLevel {
|
|
| 280 |
- entry := logger.newEntry() |
|
| 281 |
- entry.Errorln(args...) |
|
| 282 |
- logger.releaseEntry(entry) |
|
| 283 |
- } |
|
| 284 |
-} |
|
| 285 |
- |
|
| 286 |
-func (logger *Logger) Fatalln(args ...interface{}) {
|
|
| 287 |
- if logger.Level >= FatalLevel {
|
|
| 288 |
- entry := logger.newEntry() |
|
| 289 |
- entry.Fatalln(args...) |
|
| 290 |
- logger.releaseEntry(entry) |
|
| 291 |
- } |
|
| 292 |
- Exit(1) |
|
| 293 |
-} |
|
| 294 |
- |
|
| 295 |
-func (logger *Logger) Panicln(args ...interface{}) {
|
|
| 296 |
- if logger.Level >= PanicLevel {
|
|
| 297 |
- entry := logger.newEntry() |
|
| 298 |
- entry.Panicln(args...) |
|
| 299 |
- logger.releaseEntry(entry) |
|
| 300 |
- } |
|
| 301 |
-} |
|
| 302 |
- |
|
| 303 |
-//When file is opened with appending mode, it's safe to |
|
| 304 |
-//write concurrently to a file (within 4k message on Linux). |
|
| 305 |
-//In these cases user can choose to disable the lock. |
|
| 306 |
-func (logger *Logger) SetNoLock() {
|
|
| 307 |
- logger.mu.Disable() |
|
| 308 |
-} |
| 309 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,143 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "fmt" |
|
| 5 |
- "log" |
|
| 6 |
- "strings" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-// Fields type, used to pass to `WithFields`. |
|
| 10 |
-type Fields map[string]interface{}
|
|
| 11 |
- |
|
| 12 |
-// Level type |
|
| 13 |
-type Level uint8 |
|
| 14 |
- |
|
| 15 |
-// Convert the Level to a string. E.g. PanicLevel becomes "panic". |
|
| 16 |
-func (level Level) String() string {
|
|
| 17 |
- switch level {
|
|
| 18 |
- case DebugLevel: |
|
| 19 |
- return "debug" |
|
| 20 |
- case InfoLevel: |
|
| 21 |
- return "info" |
|
| 22 |
- case WarnLevel: |
|
| 23 |
- return "warning" |
|
| 24 |
- case ErrorLevel: |
|
| 25 |
- return "error" |
|
| 26 |
- case FatalLevel: |
|
| 27 |
- return "fatal" |
|
| 28 |
- case PanicLevel: |
|
| 29 |
- return "panic" |
|
| 30 |
- } |
|
| 31 |
- |
|
| 32 |
- return "unknown" |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-// ParseLevel takes a string level and returns the Logrus log level constant. |
|
| 36 |
-func ParseLevel(lvl string) (Level, error) {
|
|
| 37 |
- switch strings.ToLower(lvl) {
|
|
| 38 |
- case "panic": |
|
| 39 |
- return PanicLevel, nil |
|
| 40 |
- case "fatal": |
|
| 41 |
- return FatalLevel, nil |
|
| 42 |
- case "error": |
|
| 43 |
- return ErrorLevel, nil |
|
| 44 |
- case "warn", "warning": |
|
| 45 |
- return WarnLevel, nil |
|
| 46 |
- case "info": |
|
| 47 |
- return InfoLevel, nil |
|
| 48 |
- case "debug": |
|
| 49 |
- return DebugLevel, nil |
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- var l Level |
|
| 53 |
- return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
|
|
| 54 |
-} |
|
| 55 |
- |
|
| 56 |
-// A constant exposing all logging levels |
|
| 57 |
-var AllLevels = []Level{
|
|
| 58 |
- PanicLevel, |
|
| 59 |
- FatalLevel, |
|
| 60 |
- ErrorLevel, |
|
| 61 |
- WarnLevel, |
|
| 62 |
- InfoLevel, |
|
| 63 |
- DebugLevel, |
|
| 64 |
-} |
|
| 65 |
- |
|
| 66 |
-// These are the different logging levels. You can set the logging level to log |
|
| 67 |
-// on your instance of logger, obtained with `logrus.New()`. |
|
| 68 |
-const ( |
|
| 69 |
- // PanicLevel level, highest level of severity. Logs and then calls panic with the |
|
| 70 |
- // message passed to Debug, Info, ... |
|
| 71 |
- PanicLevel Level = iota |
|
| 72 |
- // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the |
|
| 73 |
- // logging level is set to Panic. |
|
| 74 |
- FatalLevel |
|
| 75 |
- // ErrorLevel level. Logs. Used for errors that should definitely be noted. |
|
| 76 |
- // Commonly used for hooks to send errors to an error tracking service. |
|
| 77 |
- ErrorLevel |
|
| 78 |
- // WarnLevel level. Non-critical entries that deserve eyes. |
|
| 79 |
- WarnLevel |
|
| 80 |
- // InfoLevel level. General operational entries about what's going on inside the |
|
| 81 |
- // application. |
|
| 82 |
- InfoLevel |
|
| 83 |
- // DebugLevel level. Usually only enabled when debugging. Very verbose logging. |
|
| 84 |
- DebugLevel |
|
| 85 |
-) |
|
| 86 |
- |
|
| 87 |
-// Won't compile if StdLogger can't be realized by a log.Logger |
|
| 88 |
-var ( |
|
| 89 |
- _ StdLogger = &log.Logger{}
|
|
| 90 |
- _ StdLogger = &Entry{}
|
|
| 91 |
- _ StdLogger = &Logger{}
|
|
| 92 |
-) |
|
| 93 |
- |
|
| 94 |
-// StdLogger is what your logrus-enabled library should take, that way |
|
| 95 |
-// it'll accept a stdlib logger and a logrus logger. There's no standard |
|
| 96 |
-// interface, this is the closest we get, unfortunately. |
|
| 97 |
-type StdLogger interface {
|
|
| 98 |
- Print(...interface{})
|
|
| 99 |
- Printf(string, ...interface{})
|
|
| 100 |
- Println(...interface{})
|
|
| 101 |
- |
|
| 102 |
- Fatal(...interface{})
|
|
| 103 |
- Fatalf(string, ...interface{})
|
|
| 104 |
- Fatalln(...interface{})
|
|
| 105 |
- |
|
| 106 |
- Panic(...interface{})
|
|
| 107 |
- Panicf(string, ...interface{})
|
|
| 108 |
- Panicln(...interface{})
|
|
| 109 |
-} |
|
| 110 |
- |
|
| 111 |
-// The FieldLogger interface generalizes the Entry and Logger types |
|
| 112 |
-type FieldLogger interface {
|
|
| 113 |
- WithField(key string, value interface{}) *Entry
|
|
| 114 |
- WithFields(fields Fields) *Entry |
|
| 115 |
- WithError(err error) *Entry |
|
| 116 |
- |
|
| 117 |
- Debugf(format string, args ...interface{})
|
|
| 118 |
- Infof(format string, args ...interface{})
|
|
| 119 |
- Printf(format string, args ...interface{})
|
|
| 120 |
- Warnf(format string, args ...interface{})
|
|
| 121 |
- Warningf(format string, args ...interface{})
|
|
| 122 |
- Errorf(format string, args ...interface{})
|
|
| 123 |
- Fatalf(format string, args ...interface{})
|
|
| 124 |
- Panicf(format string, args ...interface{})
|
|
| 125 |
- |
|
| 126 |
- Debug(args ...interface{})
|
|
| 127 |
- Info(args ...interface{})
|
|
| 128 |
- Print(args ...interface{})
|
|
| 129 |
- Warn(args ...interface{})
|
|
| 130 |
- Warning(args ...interface{})
|
|
| 131 |
- Error(args ...interface{})
|
|
| 132 |
- Fatal(args ...interface{})
|
|
| 133 |
- Panic(args ...interface{})
|
|
| 134 |
- |
|
| 135 |
- Debugln(args ...interface{})
|
|
| 136 |
- Infoln(args ...interface{})
|
|
| 137 |
- Println(args ...interface{})
|
|
| 138 |
- Warnln(args ...interface{})
|
|
| 139 |
- Warningln(args ...interface{})
|
|
| 140 |
- Errorln(args ...interface{})
|
|
| 141 |
- Fatalln(args ...interface{})
|
|
| 142 |
- Panicln(args ...interface{})
|
|
| 143 |
-} |
| 11 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,14 +0,0 @@ |
| 1 |
-// Based on ssh/terminal: |
|
| 2 |
-// Copyright 2013 The Go Authors. All rights reserved. |
|
| 3 |
-// Use of this source code is governed by a BSD-style |
|
| 4 |
-// license that can be found in the LICENSE file. |
|
| 5 |
- |
|
| 6 |
-// +build !appengine |
|
| 7 |
- |
|
| 8 |
-package logrus |
|
| 9 |
- |
|
| 10 |
-import "syscall" |
|
| 11 |
- |
|
| 12 |
-const ioctlReadTermios = syscall.TCGETS |
|
| 13 |
- |
|
| 14 |
-type Termios syscall.Termios |
| 15 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,22 +0,0 @@ |
| 1 |
-// Based on ssh/terminal: |
|
| 2 |
-// Copyright 2011 The Go Authors. All rights reserved. |
|
| 3 |
-// Use of this source code is governed by a BSD-style |
|
| 4 |
-// license that can be found in the LICENSE file. |
|
| 5 |
- |
|
| 6 |
-// +build linux darwin freebsd openbsd netbsd dragonfly |
|
| 7 |
-// +build !appengine |
|
| 8 |
- |
|
| 9 |
-package logrus |
|
| 10 |
- |
|
| 11 |
-import ( |
|
| 12 |
- "syscall" |
|
| 13 |
- "unsafe" |
|
| 14 |
-) |
|
| 15 |
- |
|
| 16 |
-// IsTerminal returns true if stderr's file descriptor is a terminal. |
|
| 17 |
-func IsTerminal() bool {
|
|
| 18 |
- fd := syscall.Stderr |
|
| 19 |
- var termios Termios |
|
| 20 |
- _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) |
|
| 21 |
- return err == 0 |
|
| 22 |
-} |
| 23 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,15 +0,0 @@ |
| 1 |
-// +build solaris,!appengine |
|
| 2 |
- |
|
| 3 |
-package logrus |
|
| 4 |
- |
|
| 5 |
-import ( |
|
| 6 |
- "os" |
|
| 7 |
- |
|
| 8 |
- "golang.org/x/sys/unix" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-// IsTerminal returns true if the given file descriptor is a terminal. |
|
| 12 |
-func IsTerminal() bool {
|
|
| 13 |
- _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) |
|
| 14 |
- return err == nil |
|
| 15 |
-} |
| 16 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,27 +0,0 @@ |
| 1 |
-// Based on ssh/terminal: |
|
| 2 |
-// Copyright 2011 The Go Authors. All rights reserved. |
|
| 3 |
-// Use of this source code is governed by a BSD-style |
|
| 4 |
-// license that can be found in the LICENSE file. |
|
| 5 |
- |
|
| 6 |
-// +build windows,!appengine |
|
| 7 |
- |
|
| 8 |
-package logrus |
|
| 9 |
- |
|
| 10 |
-import ( |
|
| 11 |
- "syscall" |
|
| 12 |
- "unsafe" |
|
| 13 |
-) |
|
| 14 |
- |
|
| 15 |
-var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
| 16 |
- |
|
| 17 |
-var ( |
|
| 18 |
- procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
|
| 19 |
-) |
|
| 20 |
- |
|
| 21 |
-// IsTerminal returns true if stderr's file descriptor is a terminal. |
|
| 22 |
-func IsTerminal() bool {
|
|
| 23 |
- fd := syscall.Stderr |
|
| 24 |
- var st uint32 |
|
| 25 |
- r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) |
|
| 26 |
- return r != 0 && e == 0 |
|
| 27 |
-} |
| 28 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,168 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "bytes" |
|
| 5 |
- "fmt" |
|
| 6 |
- "runtime" |
|
| 7 |
- "sort" |
|
| 8 |
- "strings" |
|
| 9 |
- "time" |
|
| 10 |
-) |
|
| 11 |
- |
|
| 12 |
-const ( |
|
| 13 |
- nocolor = 0 |
|
| 14 |
- red = 31 |
|
| 15 |
- green = 32 |
|
| 16 |
- yellow = 33 |
|
| 17 |
- blue = 34 |
|
| 18 |
- gray = 37 |
|
| 19 |
-) |
|
| 20 |
- |
|
| 21 |
-var ( |
|
| 22 |
- baseTimestamp time.Time |
|
| 23 |
- isTerminal bool |
|
| 24 |
-) |
|
| 25 |
- |
|
| 26 |
-func init() {
|
|
| 27 |
- baseTimestamp = time.Now() |
|
| 28 |
- isTerminal = IsTerminal() |
|
| 29 |
-} |
|
| 30 |
- |
|
| 31 |
-func miniTS() int {
|
|
| 32 |
- return int(time.Since(baseTimestamp) / time.Second) |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-type TextFormatter struct {
|
|
| 36 |
- // Set to true to bypass checking for a TTY before outputting colors. |
|
| 37 |
- ForceColors bool |
|
| 38 |
- |
|
| 39 |
- // Force disabling colors. |
|
| 40 |
- DisableColors bool |
|
| 41 |
- |
|
| 42 |
- // Disable timestamp logging. useful when output is redirected to logging |
|
| 43 |
- // system that already adds timestamps. |
|
| 44 |
- DisableTimestamp bool |
|
| 45 |
- |
|
| 46 |
- // Enable logging the full timestamp when a TTY is attached instead of just |
|
| 47 |
- // the time passed since beginning of execution. |
|
| 48 |
- FullTimestamp bool |
|
| 49 |
- |
|
| 50 |
- // TimestampFormat to use for display when a full timestamp is printed |
|
| 51 |
- TimestampFormat string |
|
| 52 |
- |
|
| 53 |
- // The fields are sorted by default for a consistent output. For applications |
|
| 54 |
- // that log extremely frequently and don't use the JSON formatter this may not |
|
| 55 |
- // be desired. |
|
| 56 |
- DisableSorting bool |
|
| 57 |
-} |
|
| 58 |
- |
|
| 59 |
-func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
|
| 60 |
- var b *bytes.Buffer |
|
| 61 |
- var keys []string = make([]string, 0, len(entry.Data)) |
|
| 62 |
- for k := range entry.Data {
|
|
| 63 |
- keys = append(keys, k) |
|
| 64 |
- } |
|
| 65 |
- |
|
| 66 |
- if !f.DisableSorting {
|
|
| 67 |
- sort.Strings(keys) |
|
| 68 |
- } |
|
| 69 |
- if entry.Buffer != nil {
|
|
| 70 |
- b = entry.Buffer |
|
| 71 |
- } else {
|
|
| 72 |
- b = &bytes.Buffer{}
|
|
| 73 |
- } |
|
| 74 |
- |
|
| 75 |
- prefixFieldClashes(entry.Data) |
|
| 76 |
- |
|
| 77 |
- isColorTerminal := isTerminal && (runtime.GOOS != "windows") |
|
| 78 |
- isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors |
|
| 79 |
- |
|
| 80 |
- timestampFormat := f.TimestampFormat |
|
| 81 |
- if timestampFormat == "" {
|
|
| 82 |
- timestampFormat = DefaultTimestampFormat |
|
| 83 |
- } |
|
| 84 |
- if isColored {
|
|
| 85 |
- f.printColored(b, entry, keys, timestampFormat) |
|
| 86 |
- } else {
|
|
| 87 |
- if !f.DisableTimestamp {
|
|
| 88 |
- f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) |
|
| 89 |
- } |
|
| 90 |
- f.appendKeyValue(b, "level", entry.Level.String()) |
|
| 91 |
- if entry.Message != "" {
|
|
| 92 |
- f.appendKeyValue(b, "msg", entry.Message) |
|
| 93 |
- } |
|
| 94 |
- for _, key := range keys {
|
|
| 95 |
- f.appendKeyValue(b, key, entry.Data[key]) |
|
| 96 |
- } |
|
| 97 |
- } |
|
| 98 |
- |
|
| 99 |
- b.WriteByte('\n')
|
|
| 100 |
- return b.Bytes(), nil |
|
| 101 |
-} |
|
| 102 |
- |
|
| 103 |
-func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
|
|
| 104 |
- var levelColor int |
|
| 105 |
- switch entry.Level {
|
|
| 106 |
- case DebugLevel: |
|
| 107 |
- levelColor = gray |
|
| 108 |
- case WarnLevel: |
|
| 109 |
- levelColor = yellow |
|
| 110 |
- case ErrorLevel, FatalLevel, PanicLevel: |
|
| 111 |
- levelColor = red |
|
| 112 |
- default: |
|
| 113 |
- levelColor = blue |
|
| 114 |
- } |
|
| 115 |
- |
|
| 116 |
- levelText := strings.ToUpper(entry.Level.String())[0:4] |
|
| 117 |
- |
|
| 118 |
- if !f.FullTimestamp {
|
|
| 119 |
- fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) |
|
| 120 |
- } else {
|
|
| 121 |
- fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) |
|
| 122 |
- } |
|
| 123 |
- for _, k := range keys {
|
|
| 124 |
- v := entry.Data[k] |
|
| 125 |
- fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k) |
|
| 126 |
- f.appendValue(b, v) |
|
| 127 |
- } |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-func needsQuoting(text string) bool {
|
|
| 131 |
- for _, ch := range text {
|
|
| 132 |
- if !((ch >= 'a' && ch <= 'z') || |
|
| 133 |
- (ch >= 'A' && ch <= 'Z') || |
|
| 134 |
- (ch >= '0' && ch <= '9') || |
|
| 135 |
- ch == '-' || ch == '.') {
|
|
| 136 |
- return true |
|
| 137 |
- } |
|
| 138 |
- } |
|
| 139 |
- return false |
|
| 140 |
-} |
|
| 141 |
- |
|
| 142 |
-func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
|
|
| 143 |
- |
|
| 144 |
- b.WriteString(key) |
|
| 145 |
- b.WriteByte('=')
|
|
| 146 |
- f.appendValue(b, value) |
|
| 147 |
- b.WriteByte(' ')
|
|
| 148 |
-} |
|
| 149 |
- |
|
| 150 |
-func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
|
|
| 151 |
- switch value := value.(type) {
|
|
| 152 |
- case string: |
|
| 153 |
- if !needsQuoting(value) {
|
|
| 154 |
- b.WriteString(value) |
|
| 155 |
- } else {
|
|
| 156 |
- fmt.Fprintf(b, "%q", value) |
|
| 157 |
- } |
|
| 158 |
- case error: |
|
| 159 |
- errmsg := value.Error() |
|
| 160 |
- if !needsQuoting(errmsg) {
|
|
| 161 |
- b.WriteString(errmsg) |
|
| 162 |
- } else {
|
|
| 163 |
- fmt.Fprintf(b, "%q", errmsg) |
|
| 164 |
- } |
|
| 165 |
- default: |
|
| 166 |
- fmt.Fprint(b, value) |
|
| 167 |
- } |
|
| 168 |
-} |
| 169 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,53 +0,0 @@ |
| 1 |
-package logrus |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "bufio" |
|
| 5 |
- "io" |
|
| 6 |
- "runtime" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-func (logger *Logger) Writer() *io.PipeWriter {
|
|
| 10 |
- return logger.WriterLevel(InfoLevel) |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
|
|
| 14 |
- reader, writer := io.Pipe() |
|
| 15 |
- |
|
| 16 |
- var printFunc func(args ...interface{})
|
|
| 17 |
- switch level {
|
|
| 18 |
- case DebugLevel: |
|
| 19 |
- printFunc = logger.Debug |
|
| 20 |
- case InfoLevel: |
|
| 21 |
- printFunc = logger.Info |
|
| 22 |
- case WarnLevel: |
|
| 23 |
- printFunc = logger.Warn |
|
| 24 |
- case ErrorLevel: |
|
| 25 |
- printFunc = logger.Error |
|
| 26 |
- case FatalLevel: |
|
| 27 |
- printFunc = logger.Fatal |
|
| 28 |
- case PanicLevel: |
|
| 29 |
- printFunc = logger.Panic |
|
| 30 |
- default: |
|
| 31 |
- printFunc = logger.Print |
|
| 32 |
- } |
|
| 33 |
- |
|
| 34 |
- go logger.writerScanner(reader, printFunc) |
|
| 35 |
- runtime.SetFinalizer(writer, writerFinalizer) |
|
| 36 |
- |
|
| 37 |
- return writer |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
|
|
| 41 |
- scanner := bufio.NewScanner(reader) |
|
| 42 |
- for scanner.Scan() {
|
|
| 43 |
- printFunc(scanner.Text()) |
|
| 44 |
- } |
|
| 45 |
- if err := scanner.Err(); err != nil {
|
|
| 46 |
- logger.Errorf("Error while reading from Writer: %s", err)
|
|
| 47 |
- } |
|
| 48 |
- reader.Close() |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-func writerFinalizer(writer *io.PipeWriter) {
|
|
| 52 |
- writer.Close() |
|
| 53 |
-} |
| ... | ... |
@@ -12,9 +12,9 @@ import ( |
| 12 | 12 |
"syscall" |
| 13 | 13 |
"time" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
"github.com/containerd/containerd/specs" |
| 17 | 16 |
ocs "github.com/opencontainers/runtime-spec/specs-go" |
| 17 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 18 |
"golang.org/x/net/context" |
| 19 | 19 |
"golang.org/x/sys/unix" |
| 20 | 20 |
) |
| ... | ... |
@@ -76,8 +76,7 @@ may be the better choice. |
| 76 | 76 |
For those who have previously deployed their own registry based on the Registry |
| 77 | 77 |
1.0 implementation and wish to deploy a Registry 2.0 while retaining images, |
| 78 | 78 |
data migration is required. A tool to assist with migration efforts has been |
| 79 |
-created. For more information see [docker/migrator] |
|
| 80 |
-(https://github.com/docker/migrator). |
|
| 79 |
+created. For more information see [docker/migrator](https://github.com/docker/migrator). |
|
| 81 | 80 |
|
| 82 | 81 |
## Contribute |
| 83 | 82 |
|
| ... | ... |
@@ -152,7 +152,7 @@ type BlobProvider interface {
|
| 152 | 152 |
|
| 153 | 153 |
// BlobServer can serve blobs via http. |
| 154 | 154 |
type BlobServer interface {
|
| 155 |
- // ServeBlob attempts to serve the blob, identifed by dgst, via http. The |
|
| 155 |
+ // ServeBlob attempts to serve the blob, identified by dgst, via http. The |
|
| 156 | 156 |
// service may decide to redirect the client elsewhere or serve the data |
| 157 | 157 |
// directly. |
| 158 | 158 |
// |
| ... | ... |
@@ -64,7 +64,7 @@ |
| 64 | 64 |
// Note that this only affects the new context, the previous context, with the |
| 65 | 65 |
// version field, can be used independently. Put another way, the new logger, |
| 66 | 66 |
// added to the request context, is unique to that context and can have |
| 67 |
-// request scoped varaibles. |
|
| 67 |
+// request scoped variables. |
|
| 68 | 68 |
// |
| 69 | 69 |
// HTTP Requests |
| 70 | 70 |
// |
| ... | ... |
@@ -77,7 +77,7 @@ func (err ErrManifestUnknownRevision) Error() string {
|
| 77 | 77 |
type ErrManifestUnverified struct{}
|
| 78 | 78 |
|
| 79 | 79 |
func (ErrManifestUnverified) Error() string {
|
| 80 |
- return fmt.Sprintf("unverified manifest")
|
|
| 80 |
+ return "unverified manifest" |
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
// ErrManifestVerification provides a type to collect errors encountered |
| ... | ... |
@@ -81,7 +81,7 @@ type ManifestList struct {
|
| 81 | 81 |
Manifests []ManifestDescriptor `json:"manifests"` |
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 |
-// References returnes the distribution descriptors for the referenced image |
|
| 84 |
+// References returns the distribution descriptors for the referenced image |
|
| 85 | 85 |
// manifests. |
| 86 | 86 |
func (m ManifestList) References() []distribution.Descriptor {
|
| 87 | 87 |
dependencies := make([]distribution.Descriptor, len(m.Manifests)) |
| ... | ... |
@@ -15,7 +15,7 @@ |
| 15 | 15 |
// tag := /[\w][\w.-]{0,127}/
|
| 16 | 16 |
// |
| 17 | 17 |
// digest := digest-algorithm ":" digest-hex |
| 18 |
-// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ] |
|
| 18 |
+// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ]* |
|
| 19 | 19 |
// digest-algorithm-separator := /[+.-_]/ |
| 20 | 20 |
// digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/ |
| 21 | 21 |
// digest-hex := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value
|
| ... | ... |
@@ -1,10 +1,9 @@ |
| 1 | 1 |
package v2 |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "net" |
|
| 4 |
+ "fmt" |
|
| 5 | 5 |
"net/http" |
| 6 | 6 |
"net/url" |
| 7 |
- "strconv" |
|
| 8 | 7 |
"strings" |
| 9 | 8 |
|
| 10 | 9 |
"github.com/docker/distribution/reference" |
| ... | ... |
@@ -48,66 +47,42 @@ func NewURLBuilderFromString(root string, relative bool) (*URLBuilder, error) {
|
| 48 | 48 |
// NewURLBuilderFromRequest uses information from an *http.Request to |
| 49 | 49 |
// construct the root url. |
| 50 | 50 |
func NewURLBuilderFromRequest(r *http.Request, relative bool) *URLBuilder {
|
| 51 |
- var scheme string |
|
| 52 |
- |
|
| 53 |
- forwardedProto := r.Header.Get("X-Forwarded-Proto")
|
|
| 54 |
- // TODO: log the error |
|
| 55 |
- forwardedHeader, _, _ := parseForwardedHeader(r.Header.Get("Forwarded"))
|
|
| 56 |
- |
|
| 57 |
- switch {
|
|
| 58 |
- case len(forwardedProto) > 0: |
|
| 59 |
- scheme = forwardedProto |
|
| 60 |
- case len(forwardedHeader["proto"]) > 0: |
|
| 61 |
- scheme = forwardedHeader["proto"] |
|
| 62 |
- case r.TLS != nil: |
|
| 63 |
- scheme = "https" |
|
| 64 |
- case len(r.URL.Scheme) > 0: |
|
| 65 |
- scheme = r.URL.Scheme |
|
| 66 |
- default: |
|
| 51 |
+ var ( |
|
| 67 | 52 |
scheme = "http" |
| 68 |
- } |
|
| 53 |
+ host = r.Host |
|
| 54 |
+ ) |
|
| 69 | 55 |
|
| 70 |
- host := r.Host |
|
| 71 |
- |
|
| 72 |
- if forwardedHost := r.Header.Get("X-Forwarded-Host"); len(forwardedHost) > 0 {
|
|
| 73 |
- // According to the Apache mod_proxy docs, X-Forwarded-Host can be a |
|
| 74 |
- // comma-separated list of hosts, to which each proxy appends the |
|
| 75 |
- // requested host. We want to grab the first from this comma-separated |
|
| 76 |
- // list. |
|
| 77 |
- hosts := strings.SplitN(forwardedHost, ",", 2) |
|
| 78 |
- host = strings.TrimSpace(hosts[0]) |
|
| 79 |
- } else if addr, exists := forwardedHeader["for"]; exists {
|
|
| 80 |
- host = addr |
|
| 81 |
- } else if h, exists := forwardedHeader["host"]; exists {
|
|
| 82 |
- host = h |
|
| 56 |
+ if r.TLS != nil {
|
|
| 57 |
+ scheme = "https" |
|
| 58 |
+ } else if len(r.URL.Scheme) > 0 {
|
|
| 59 |
+ scheme = r.URL.Scheme |
|
| 83 | 60 |
} |
| 84 | 61 |
|
| 85 |
- portLessHost, port := host, "" |
|
| 86 |
- if !isIPv6Address(portLessHost) {
|
|
| 87 |
- // with go 1.6, this would treat the last part of IPv6 address as a port |
|
| 88 |
- portLessHost, port, _ = net.SplitHostPort(host) |
|
| 89 |
- } |
|
| 90 |
- if forwardedPort := r.Header.Get("X-Forwarded-Port"); len(port) == 0 && len(forwardedPort) > 0 {
|
|
| 91 |
- ports := strings.SplitN(forwardedPort, ",", 2) |
|
| 92 |
- forwardedPort = strings.TrimSpace(ports[0]) |
|
| 93 |
- if _, err := strconv.ParseInt(forwardedPort, 10, 32); err == nil {
|
|
| 94 |
- port = forwardedPort |
|
| 62 |
+ // Handle fowarded headers |
|
| 63 |
+ // Prefer "Forwarded" header as defined by rfc7239 if given |
|
| 64 |
+ // see https://tools.ietf.org/html/rfc7239 |
|
| 65 |
+ if forwarded := r.Header.Get("Forwarded"); len(forwarded) > 0 {
|
|
| 66 |
+ forwardedHeader, _, err := parseForwardedHeader(forwarded) |
|
| 67 |
+ if err == nil {
|
|
| 68 |
+ if fproto := forwardedHeader["proto"]; len(fproto) > 0 {
|
|
| 69 |
+ scheme = fproto |
|
| 70 |
+ } |
|
| 71 |
+ if fhost := forwardedHeader["host"]; len(fhost) > 0 {
|
|
| 72 |
+ host = fhost |
|
| 73 |
+ } |
|
| 95 | 74 |
} |
| 96 |
- } |
|
| 97 |
- |
|
| 98 |
- if len(portLessHost) > 0 {
|
|
| 99 |
- host = portLessHost |
|
| 100 |
- } |
|
| 101 |
- if len(port) > 0 {
|
|
| 102 |
- // remove enclosing brackets of ipv6 address otherwise they will be duplicated |
|
| 103 |
- if len(host) > 1 && host[0] == '[' && host[len(host)-1] == ']' {
|
|
| 104 |
- host = host[1 : len(host)-1] |
|
| 75 |
+ } else {
|
|
| 76 |
+ if forwardedProto := r.Header.Get("X-Forwarded-Proto"); len(forwardedProto) > 0 {
|
|
| 77 |
+ scheme = forwardedProto |
|
| 78 |
+ } |
|
| 79 |
+ if forwardedHost := r.Header.Get("X-Forwarded-Host"); len(forwardedHost) > 0 {
|
|
| 80 |
+ // According to the Apache mod_proxy docs, X-Forwarded-Host can be a |
|
| 81 |
+ // comma-separated list of hosts, to which each proxy appends the |
|
| 82 |
+ // requested host. We want to grab the first from this comma-separated |
|
| 83 |
+ // list. |
|
| 84 |
+ hosts := strings.SplitN(forwardedHost, ",", 2) |
|
| 85 |
+ host = strings.TrimSpace(hosts[0]) |
|
| 105 | 86 |
} |
| 106 |
- // JoinHostPort properly encloses ipv6 addresses in square brackets |
|
| 107 |
- host = net.JoinHostPort(host, port) |
|
| 108 |
- } else if isIPv6Address(host) && host[0] != '[' {
|
|
| 109 |
- // ipv6 needs to be enclosed in square brackets in urls |
|
| 110 |
- host = "[" + host + "]" |
|
| 111 | 87 |
} |
| 112 | 88 |
|
| 113 | 89 |
basePath := routeDescriptorsMap[RouteNameBase].Path |
| ... | ... |
@@ -175,6 +150,8 @@ func (ub *URLBuilder) BuildManifestURL(ref reference.Named) (string, error) {
|
| 175 | 175 |
tagOrDigest = v.Tag() |
| 176 | 176 |
case reference.Digested: |
| 177 | 177 |
tagOrDigest = v.Digest().String() |
| 178 |
+ default: |
|
| 179 |
+ return "", fmt.Errorf("reference must have a tag or digest")
|
|
| 178 | 180 |
} |
| 179 | 181 |
|
| 180 | 182 |
manifestURL, err := route.URL("name", ref.Name(), "reference", tagOrDigest)
|
| ... | ... |
@@ -287,28 +264,3 @@ func appendValues(u string, values ...url.Values) string {
|
| 287 | 287 |
|
| 288 | 288 |
return appendValuesURL(up, values...).String() |
| 289 | 289 |
} |
| 290 |
- |
|
| 291 |
-// isIPv6Address returns true if given string is a valid IPv6 address. No port is allowed. The address may be |
|
| 292 |
-// enclosed in square brackets. |
|
| 293 |
-func isIPv6Address(host string) bool {
|
|
| 294 |
- if len(host) > 1 && host[0] == '[' && host[len(host)-1] == ']' {
|
|
| 295 |
- host = host[1 : len(host)-1] |
|
| 296 |
- } |
|
| 297 |
- // The IPv6 scoped addressing zone identifier starts after the last percent sign. |
|
| 298 |
- if i := strings.LastIndexByte(host, '%'); i > 0 {
|
|
| 299 |
- host = host[:i] |
|
| 300 |
- } |
|
| 301 |
- ip := net.ParseIP(host) |
|
| 302 |
- if ip == nil {
|
|
| 303 |
- return false |
|
| 304 |
- } |
|
| 305 |
- if ip.To16() == nil {
|
|
| 306 |
- return false |
|
| 307 |
- } |
|
| 308 |
- if ip.To4() == nil {
|
|
| 309 |
- return true |
|
| 310 |
- } |
|
| 311 |
- // dot can be present in ipv4-mapped address, it needs to come after a colon though |
|
| 312 |
- i := strings.IndexAny(host, ":.") |
|
| 313 |
- return i >= 0 && host[i] == ':' |
|
| 314 |
-} |
| ... | ... |
@@ -10,10 +10,10 @@ import ( |
| 10 | 10 |
"sync" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/distribution/registry/client" |
| 15 | 14 |
"github.com/docker/distribution/registry/client/auth/challenge" |
| 16 | 15 |
"github.com/docker/distribution/registry/client/transport" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
var ( |
| ... | ... |
@@ -1,19 +1,21 @@ |
| 1 |
-github.com/Azure/azure-sdk-for-go c6f0533defaaaa26ea4dff3c9774e36033088112 |
|
| 2 |
-github.com/Sirupsen/logrus d26492970760ca5d33129d2d799e34be5c4782eb |
|
| 1 |
+github.com/Azure/azure-sdk-for-go 088007b3b08cc02b27f2eadfdcd870958460ce7e |
|
| 2 |
+github.com/Azure/go-autorest ec5f4903f77ed9927ac95b19ab8e44ada64c1356 |
|
| 3 |
+github.com/sirupsen/logrus 3d4380f53a34dcdc95f0c1db702615992b38d9a4 |
|
| 3 | 4 |
github.com/aws/aws-sdk-go c6fc52983ea2375810aa38ddb5370e9cdf611716 |
| 4 |
-github.com/bshuster-repo/logrus-logstash-hook 5f729f2fb50a301153cae84ff5c58981d51c095a |
|
| 5 |
+github.com/bshuster-repo/logrus-logstash-hook d2c0ecc1836d91814e15e23bb5dc309c3ef51f4a |
|
| 5 | 6 |
github.com/bugsnag/bugsnag-go b1d153021fcd90ca3f080db36bec96dc690fb274 |
| 6 | 7 |
github.com/bugsnag/osext 0dd3f918b21bec95ace9dc86c7e70266cfc5c702 |
| 7 | 8 |
github.com/bugsnag/panicwrap e2c28503fcd0675329da73bf48b33404db873782 |
| 8 | 9 |
github.com/denverdino/aliyungo afedced274aa9a7fcdd47ac97018f0f8db4e5de2 |
| 10 |
+github.com/dgrijalva/jwt-go a601269ab70c205d26370c16f7c81e9017c14e04 |
|
| 9 | 11 |
github.com/docker/goamz f0a21f5b2e12f83a505ecf79b633bb2035cf6f85 |
| 10 | 12 |
github.com/docker/libtrust fa567046d9b14f6aa788882a950d69651d230b21 |
| 11 | 13 |
github.com/garyburd/redigo 535138d7bcd717d6531c701ef5933d98b1866257 |
| 12 | 14 |
github.com/go-ini/ini 2ba15ac2dc9cdf88c110ec2dc0ced7fa45f5678c |
| 13 |
-github.com/golang/protobuf/proto 8d92cf5fc15a4382f8964b08e1f42a75c0591aa3 |
|
| 15 |
+github.com/golang/protobuf 8d92cf5fc15a4382f8964b08e1f42a75c0591aa3 |
|
| 14 | 16 |
github.com/gorilla/context 14f550f51af52180c2eefed15e5fd18d63c0a64a |
| 15 | 17 |
github.com/gorilla/handlers 60c7bfde3e33c201519a200a4507a158cc03a17b |
| 16 |
-github.com/gorilla/mux e444e69cbd2e2e3e0749a2f3c717cec491552bbf |
|
| 18 |
+github.com/gorilla/mux 599cba5e7b6137d46ddf58fb1765f5d928e69604 |
|
| 17 | 19 |
github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 |
| 18 | 20 |
github.com/jmespath/go-jmespath bd40a432e4c76585ef6b72d3fd96fb9b6dc7b68d |
| 19 | 21 |
github.com/miekg/dns 271c58e0c14f552178ea321a545ff9af38930f39 |
| ... | ... |
@@ -21,15 +23,15 @@ github.com/mitchellh/mapstructure 482a9fd5fa83e8c4e7817413b80f3eb8feec03ef |
| 21 | 21 |
github.com/ncw/swift b964f2ca856aac39885e258ad25aec08d5f64ee6 |
| 22 | 22 |
github.com/spf13/cobra 312092086bed4968099259622145a0c9ae280064 |
| 23 | 23 |
github.com/spf13/pflag 5644820622454e71517561946e3d94b9f9db6842 |
| 24 |
-github.com/stevvooe/resumable 51ad44105773cafcbe91927f70ac68e1bf78f8b4 |
|
| 25 |
-github.com/xenolf/lego/acme a9d8cec0e6563575e5868a005359ac97911b5985 |
|
| 24 |
+github.com/stevvooe/resumable 2aaf90b2ceea5072cb503ef2a620b08ff3119870 |
|
| 25 |
+github.com/xenolf/lego a9d8cec0e6563575e5868a005359ac97911b5985 |
|
| 26 | 26 |
github.com/yvasiyarov/go-metrics 57bccd1ccd43f94bb17fdd8bf3007059b802f85e |
| 27 | 27 |
github.com/yvasiyarov/gorelic a9bba5b9ab508a086f9a12b8c51fab68478e2128 |
| 28 | 28 |
github.com/yvasiyarov/newrelic_platform_go b21fdbd4370f3717f3bbd2bf41c223bc273068e6 |
| 29 | 29 |
golang.org/x/crypto c10c31b5e94b6f7a0283272dc2bb27163dcea24b |
| 30 | 30 |
golang.org/x/net 4876518f9e71663000c348837735820161a42df7 |
| 31 | 31 |
golang.org/x/oauth2 045497edb6234273d67dbc25da3f2ddbc4c4cacf |
| 32 |
-golang.org/x/time/rate a4bde12657593d5e90d0533a3e4fd95e635124cb |
|
| 32 |
+golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb |
|
| 33 | 33 |
google.golang.org/api 9bf6e6e569ff057f75d9604a46c52928f17d2b54 |
| 34 | 34 |
google.golang.org/appengine 12d5545dc1cfa6047a286d5e853841b6471f4c19 |
| 35 | 35 |
google.golang.org/cloud 975617b05ea8a58727e6c1a06b6161ff4185a9f2 |
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"sync" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 7 |
+ "github.com/sirupsen/logrus" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
// Broadcaster sends events to multiple, reliable Sinks. The goal of this |
| ... | ... |
@@ -160,7 +160,7 @@ func (b *Broadcaster) run() {
|
| 160 | 160 |
} |
| 161 | 161 |
} |
| 162 | 162 |
|
| 163 |
-func (b Broadcaster) String() string {
|
|
| 163 |
+func (b *Broadcaster) String() string {
|
|
| 164 | 164 |
// Serialize copy of this broadcaster without the sync.Once, to avoid |
| 165 | 165 |
// a data race. |
| 166 | 166 |
|
| ... | ... |
@@ -50,7 +50,7 @@ func (ch *Channel) Close() error {
|
| 50 | 50 |
return nil |
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 |
-func (ch Channel) String() string {
|
|
| 53 |
+func (ch *Channel) String() string {
|
|
| 54 | 54 |
// Serialize a copy of the Channel that doesn't contain the sync.Once, |
| 55 | 55 |
// to avoid a data race. |
| 56 | 56 |
ch2 := map[string]interface{}{
|
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"container/list" |
| 5 | 5 |
"sync" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 7 |
+ "github.com/sirupsen/logrus" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
// Queue accepts all messages into a queue for asynchronous consumption |
| ... | ... |
@@ -31,7 +31,7 @@ func NewQueue(dst Sink) *Queue {
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
// Write accepts the events into the queue, only failing if the queue has |
| 34 |
-// beend closed. |
|
| 34 |
+// been closed. |
|
| 35 | 35 |
func (eq *Queue) Write(event Event) error {
|
| 36 | 36 |
eq.mu.Lock() |
| 37 | 37 |
defer eq.mu.Unlock() |
| ... | ... |
@@ -7,7 +7,7 @@ import ( |
| 7 | 7 |
"sync/atomic" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// RetryingSink retries the write until success or an ErrSinkClosed is |
| ... | ... |
@@ -90,7 +90,7 @@ func (rs *RetryingSink) Close() error {
|
| 90 | 90 |
return nil |
| 91 | 91 |
} |
| 92 | 92 |
|
| 93 |
-func (rs RetryingSink) String() string {
|
|
| 93 |
+func (rs *RetryingSink) String() string {
|
|
| 94 | 94 |
// Serialize a copy of the RetryingSink without the sync.Once, to avoid |
| 95 | 95 |
// a data race. |
| 96 | 96 |
rs2 := map[string]interface{}{
|
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"sort" |
| 11 | 11 |
"sync" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/docker/pkg/stringid" |
| 15 | 14 |
"github.com/docker/go-events" |
| 16 | 15 |
"github.com/docker/libnetwork/cluster" |
| ... | ... |
@@ -20,6 +19,7 @@ import ( |
| 20 | 20 |
"github.com/docker/libnetwork/networkdb" |
| 21 | 21 |
"github.com/docker/libnetwork/types" |
| 22 | 22 |
"github.com/gogo/protobuf/proto" |
| 23 |
+ "github.com/sirupsen/logrus" |
|
| 23 | 24 |
) |
| 24 | 25 |
|
| 25 | 26 |
const ( |
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"strings" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/BurntSushi/toml" |
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/pkg/discovery" |
| 9 | 8 |
"github.com/docker/docker/pkg/plugingetter" |
| 10 | 9 |
"github.com/docker/go-connections/tlsconfig" |
| ... | ... |
@@ -13,6 +12,7 @@ import ( |
| 13 | 13 |
"github.com/docker/libnetwork/datastore" |
| 14 | 14 |
"github.com/docker/libnetwork/netlabel" |
| 15 | 15 |
"github.com/docker/libnetwork/osl" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 17 |
) |
| 17 | 18 |
|
| 18 | 19 |
// Config encapsulates configurations of various Libnetwork components |
| ... | ... |
@@ -52,7 +52,6 @@ import ( |
| 52 | 52 |
"sync" |
| 53 | 53 |
"time" |
| 54 | 54 |
|
| 55 |
- "github.com/Sirupsen/logrus" |
|
| 56 | 55 |
"github.com/docker/docker/pkg/discovery" |
| 57 | 56 |
"github.com/docker/docker/pkg/locker" |
| 58 | 57 |
"github.com/docker/docker/pkg/plugingetter" |
| ... | ... |
@@ -69,6 +68,7 @@ import ( |
| 69 | 69 |
"github.com/docker/libnetwork/netlabel" |
| 70 | 70 |
"github.com/docker/libnetwork/osl" |
| 71 | 71 |
"github.com/docker/libnetwork/types" |
| 72 |
+ "github.com/sirupsen/logrus" |
|
| 72 | 73 |
) |
| 73 | 74 |
|
| 74 | 75 |
// NetworkController provides the interface for controller instance which manages |
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"sync" |
| 13 | 13 |
"syscall" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
"github.com/docker/libnetwork/datastore" |
| 17 | 16 |
"github.com/docker/libnetwork/discoverapi" |
| 18 | 17 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -24,6 +23,7 @@ import ( |
| 24 | 24 |
"github.com/docker/libnetwork/osl" |
| 25 | 25 |
"github.com/docker/libnetwork/portmapper" |
| 26 | 26 |
"github.com/docker/libnetwork/types" |
| 27 |
+ "github.com/sirupsen/logrus" |
|
| 27 | 28 |
"github.com/vishvananda/netlink" |
| 28 | 29 |
) |
| 29 | 30 |
|
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/datastore" |
| 10 | 9 |
"github.com/docker/libnetwork/discoverapi" |
| 11 | 10 |
"github.com/docker/libnetwork/netlabel" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
const ( |
| ... | ... |
@@ -3,12 +3,12 @@ package ipvlan |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/libnetwork/driverapi" |
| 8 | 7 |
"github.com/docker/libnetwork/netlabel" |
| 9 | 8 |
"github.com/docker/libnetwork/ns" |
| 10 | 9 |
"github.com/docker/libnetwork/osl" |
| 11 | 10 |
"github.com/docker/libnetwork/types" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// CreateEndpoint assigns the mac, ip and endpoint id for the new container |
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/libnetwork/driverapi" |
| 9 | 8 |
"github.com/docker/libnetwork/netutils" |
| 10 | 9 |
"github.com/docker/libnetwork/ns" |
| 11 | 10 |
"github.com/docker/libnetwork/osl" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
type staticRoute struct {
|
| ... | ... |
@@ -3,7 +3,6 @@ package ipvlan |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/docker/pkg/parsers/kernel" |
| 8 | 7 |
"github.com/docker/docker/pkg/stringid" |
| 9 | 8 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -12,6 +11,7 @@ import ( |
| 12 | 12 |
"github.com/docker/libnetwork/options" |
| 13 | 13 |
"github.com/docker/libnetwork/osl" |
| 14 | 14 |
"github.com/docker/libnetwork/types" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 | 18 |
// CreateNetwork the network for the specified driver type |
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/datastore" |
| 10 | 9 |
"github.com/docker/libnetwork/discoverapi" |
| 11 | 10 |
"github.com/docker/libnetwork/netlabel" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
const ( |
| ... | ... |
@@ -3,13 +3,13 @@ package macvlan |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/libnetwork/driverapi" |
| 8 | 7 |
"github.com/docker/libnetwork/netlabel" |
| 9 | 8 |
"github.com/docker/libnetwork/netutils" |
| 10 | 9 |
"github.com/docker/libnetwork/ns" |
| 11 | 10 |
"github.com/docker/libnetwork/osl" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
// CreateEndpoint assigns the mac, ip and endpoint id for the new container |
| ... | ... |
@@ -4,11 +4,11 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/libnetwork/driverapi" |
| 9 | 8 |
"github.com/docker/libnetwork/netutils" |
| 10 | 9 |
"github.com/docker/libnetwork/ns" |
| 11 | 10 |
"github.com/docker/libnetwork/osl" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| ... | ... |
@@ -3,7 +3,6 @@ package macvlan |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/docker/pkg/parsers/kernel" |
| 8 | 7 |
"github.com/docker/docker/pkg/stringid" |
| 9 | 8 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -12,6 +11,7 @@ import ( |
| 12 | 12 |
"github.com/docker/libnetwork/options" |
| 13 | 13 |
"github.com/docker/libnetwork/osl" |
| 14 | 14 |
"github.com/docker/libnetwork/types" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 | 18 |
// CreateNetwork the network for the specified driver type |
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/datastore" |
| 10 | 9 |
"github.com/docker/libnetwork/discoverapi" |
| 11 | 10 |
"github.com/docker/libnetwork/netlabel" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
const ( |
| ... | ... |
@@ -12,10 +12,10 @@ import ( |
| 12 | 12 |
|
| 13 | 13 |
"strconv" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
"github.com/docker/libnetwork/iptables" |
| 17 | 16 |
"github.com/docker/libnetwork/ns" |
| 18 | 17 |
"github.com/docker/libnetwork/types" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 19 |
"github.com/vishvananda/netlink" |
| 20 | 20 |
) |
| 21 | 21 |
|
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"net" |
| 6 | 6 |
"syscall" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/driverapi" |
| 10 | 9 |
"github.com/docker/libnetwork/ns" |
| 11 | 10 |
"github.com/docker/libnetwork/types" |
| 12 | 11 |
"github.com/gogo/protobuf/proto" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| ... | ... |
@@ -5,12 +5,12 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/datastore" |
| 10 | 9 |
"github.com/docker/libnetwork/driverapi" |
| 11 | 10 |
"github.com/docker/libnetwork/netutils" |
| 12 | 11 |
"github.com/docker/libnetwork/ns" |
| 13 | 12 |
"github.com/docker/libnetwork/types" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
type endpointTable map[string]*endpoint |
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"syscall" |
| 15 | 15 |
"time" |
| 16 | 16 |
|
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/docker/docker/pkg/reexec" |
| 19 | 18 |
"github.com/docker/libnetwork/datastore" |
| 20 | 19 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -24,6 +23,7 @@ import ( |
| 24 | 24 |
"github.com/docker/libnetwork/osl" |
| 25 | 25 |
"github.com/docker/libnetwork/resolvconf" |
| 26 | 26 |
"github.com/docker/libnetwork/types" |
| 27 |
+ "github.com/sirupsen/logrus" |
|
| 27 | 28 |
"github.com/vishvananda/netlink" |
| 28 | 29 |
"github.com/vishvananda/netlink/nl" |
| 29 | 30 |
"github.com/vishvananda/netns" |
| ... | ... |
@@ -5,10 +5,10 @@ import ( |
| 5 | 5 |
"strings" |
| 6 | 6 |
"syscall" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/netutils" |
| 10 | 9 |
"github.com/docker/libnetwork/ns" |
| 11 | 10 |
"github.com/docker/libnetwork/osl" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
"github.com/vishvananda/netlink" |
| 13 | 13 |
"github.com/vishvananda/netns" |
| 14 | 14 |
) |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"net" |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/libnetwork/datastore" |
| 12 | 11 |
"github.com/docker/libnetwork/discoverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -16,6 +15,7 @@ import ( |
| 16 | 16 |
"github.com/docker/libnetwork/osl" |
| 17 | 17 |
"github.com/docker/libnetwork/types" |
| 18 | 18 |
"github.com/hashicorp/serf/serf" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 20 |
) |
| 20 | 21 |
|
| 21 | 22 |
const ( |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/libnetwork/datastore" |
| 12 | 11 |
"github.com/docker/libnetwork/discoverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/driverapi" |
| 14 | 13 |
"github.com/docker/libnetwork/idm" |
| 15 | 14 |
"github.com/docker/libnetwork/netlabel" |
| 16 | 15 |
"github.com/docker/libnetwork/types" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
const ( |
| ... | ... |
@@ -5,13 +5,13 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/docker/pkg/plugins" |
| 10 | 9 |
"github.com/docker/libnetwork/datastore" |
| 11 | 10 |
"github.com/docker/libnetwork/discoverapi" |
| 12 | 11 |
"github.com/docker/libnetwork/driverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/drivers/remote/api" |
| 14 | 13 |
"github.com/docker/libnetwork/types" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
type driver struct {
|
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
"strings" |
| 14 | 14 |
"sync" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/docker/libnetwork/datastore" |
| 18 | 17 |
"github.com/docker/libnetwork/discoverapi" |
| 19 | 18 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -23,6 +22,7 @@ import ( |
| 23 | 23 |
"github.com/docker/libnetwork/options" |
| 24 | 24 |
"github.com/docker/libnetwork/portmapper" |
| 25 | 25 |
"github.com/docker/libnetwork/types" |
| 26 |
+ "github.com/sirupsen/logrus" |
|
| 26 | 27 |
) |
| 27 | 28 |
|
| 28 | 29 |
const ( |
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"fmt" |
| 8 | 8 |
"net" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/libnetwork/datastore" |
| 12 | 11 |
"github.com/docker/libnetwork/discoverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/netlabel" |
| 14 | 13 |
"github.com/docker/libnetwork/types" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
const ( |
| ... | ... |
@@ -4,10 +4,10 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/libnetwork/driverapi" |
| 9 | 8 |
"github.com/docker/libnetwork/types" |
| 10 | 9 |
"github.com/gogo/protobuf/proto" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/datastore" |
| 10 | 9 |
"github.com/docker/libnetwork/driverapi" |
| 11 | 10 |
"github.com/docker/libnetwork/netutils" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
type endpointTable map[string]*endpoint |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"sync" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/docker/libnetwork/datastore" |
| 15 | 14 |
"github.com/docker/libnetwork/driverapi" |
| 16 | 15 |
"github.com/docker/libnetwork/netlabel" |
| ... | ... |
@@ -18,6 +17,7 @@ import ( |
| 18 | 18 |
"github.com/docker/libnetwork/osl" |
| 19 | 19 |
"github.com/docker/libnetwork/resolvconf" |
| 20 | 20 |
"github.com/docker/libnetwork/types" |
| 21 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 22 |
) |
| 22 | 23 |
|
| 23 | 24 |
var ( |
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"net" |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/libnetwork/datastore" |
| 12 | 11 |
"github.com/docker/libnetwork/discoverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -16,6 +15,7 @@ import ( |
| 16 | 16 |
"github.com/docker/libnetwork/osl" |
| 17 | 17 |
"github.com/docker/libnetwork/types" |
| 18 | 18 |
"github.com/hashicorp/serf/serf" |
| 19 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 20 |
) |
| 20 | 21 |
|
| 21 | 22 |
// XXX OVERLAY_SOLARIS |
| ... | ... |
@@ -4,10 +4,10 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/libnetwork/driverapi" |
| 9 | 8 |
"github.com/docker/libnetwork/types" |
| 10 | 9 |
"github.com/gogo/protobuf/proto" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| ... | ... |
@@ -9,10 +9,10 @@ import ( |
| 9 | 9 |
"sync" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Microsoft/hcsshim" |
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/libnetwork/driverapi" |
| 14 | 13 |
"github.com/docker/libnetwork/netlabel" |
| 15 | 14 |
"github.com/docker/libnetwork/types" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
var ( |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
"sync" |
| 9 | 9 |
|
| 10 | 10 |
"github.com/Microsoft/hcsshim" |
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/libnetwork/datastore" |
| 13 | 12 |
"github.com/docker/libnetwork/discoverapi" |
| 14 | 13 |
"github.com/docker/libnetwork/driverapi" |
| 15 | 14 |
"github.com/docker/libnetwork/netlabel" |
| 16 | 15 |
"github.com/docker/libnetwork/types" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
const ( |
| ... | ... |
@@ -20,12 +20,12 @@ import ( |
| 20 | 20 |
"sync" |
| 21 | 21 |
|
| 22 | 22 |
"github.com/Microsoft/hcsshim" |
| 23 |
- "github.com/Sirupsen/logrus" |
|
| 24 | 23 |
"github.com/docker/libnetwork/datastore" |
| 25 | 24 |
"github.com/docker/libnetwork/discoverapi" |
| 26 | 25 |
"github.com/docker/libnetwork/driverapi" |
| 27 | 26 |
"github.com/docker/libnetwork/netlabel" |
| 28 | 27 |
"github.com/docker/libnetwork/types" |
| 28 |
+ "github.com/sirupsen/logrus" |
|
| 29 | 29 |
) |
| 30 | 30 |
|
| 31 | 31 |
// networkConfiguration for network specific configuration |
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"fmt" |
| 8 | 8 |
"net" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/libnetwork/datastore" |
| 12 | 11 |
"github.com/docker/libnetwork/discoverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/netlabel" |
| 14 | 13 |
"github.com/docker/libnetwork/types" |
| 14 |
+ "github.com/sirupsen/logrus" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
const ( |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"sync" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/libnetwork/datastore" |
| 13 | 12 |
"github.com/docker/libnetwork/ipamapi" |
| 14 | 13 |
"github.com/docker/libnetwork/netlabel" |
| 15 | 14 |
"github.com/docker/libnetwork/options" |
| 16 | 15 |
"github.com/docker/libnetwork/types" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
// Endpoint represents a logical connection between a network and a sandbox. |
| ... | ... |
@@ -6,13 +6,13 @@ import ( |
| 6 | 6 |
"sort" |
| 7 | 7 |
"sync" |
| 8 | 8 |
|
| 9 |
- "github.com/Sirupsen/logrus" |
|
| 10 | 9 |
"github.com/docker/libnetwork/bitseq" |
| 11 | 10 |
"github.com/docker/libnetwork/datastore" |
| 12 | 11 |
"github.com/docker/libnetwork/discoverapi" |
| 13 | 12 |
"github.com/docker/libnetwork/ipamapi" |
| 14 | 13 |
"github.com/docker/libnetwork/ipamutils" |
| 15 | 14 |
"github.com/docker/libnetwork/types" |
| 15 |
+ "github.com/sirupsen/logrus" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
const ( |
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/docker/pkg/plugins" |
| 9 | 8 |
"github.com/docker/libnetwork/discoverapi" |
| 10 | 9 |
"github.com/docker/libnetwork/ipamapi" |
| 11 | 10 |
"github.com/docker/libnetwork/ipams/remote/api" |
| 12 | 11 |
"github.com/docker/libnetwork/types" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
type allocator struct {
|
| ... | ... |
@@ -3,11 +3,11 @@ package windowsipam |
| 3 | 3 |
import ( |
| 4 | 4 |
"net" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/libnetwork/discoverapi" |
| 8 | 7 |
"github.com/docker/libnetwork/ipamapi" |
| 9 | 8 |
"github.com/docker/libnetwork/netlabel" |
| 10 | 9 |
"github.com/docker/libnetwork/types" |
| 10 |
+ "github.com/sirupsen/logrus" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
const ( |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"sync" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- "github.com/Sirupsen/logrus" |
|
| 12 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 13 | 12 |
"github.com/docker/libnetwork/common" |
| 14 | 13 |
"github.com/docker/libnetwork/config" |
| ... | ... |
@@ -21,6 +20,7 @@ import ( |
| 21 | 21 |
"github.com/docker/libnetwork/networkdb" |
| 22 | 22 |
"github.com/docker/libnetwork/options" |
| 23 | 23 |
"github.com/docker/libnetwork/types" |
| 24 |
+ "github.com/sirupsen/logrus" |
|
| 24 | 25 |
) |
| 25 | 26 |
|
| 26 | 27 |
// A Network represents a logical connectivity zone that containers may |
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/Microsoft/hcsshim" |
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/libnetwork/drivers/windows" |
| 12 | 11 |
"github.com/docker/libnetwork/ipamapi" |
| 13 | 12 |
"github.com/docker/libnetwork/ipams/windowsipam" |
| 13 |
+ "github.com/sirupsen/logrus" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
func executeInCompartment(compartmentID uint32, x func()) {
|
| ... | ... |
@@ -10,12 +10,12 @@ import ( |
| 10 | 10 |
"sync" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/Sirupsen/logrus" |
|
| 14 | 13 |
"github.com/armon/go-radix" |
| 15 | 14 |
"github.com/docker/go-events" |
| 16 | 15 |
"github.com/docker/libnetwork/types" |
| 17 | 16 |
"github.com/hashicorp/memberlist" |
| 18 | 17 |
"github.com/hashicorp/serf/serf" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 19 |
) |
| 20 | 20 |
|
| 21 | 21 |
const ( |
| ... | ... |
@@ -14,10 +14,10 @@ import ( |
| 14 | 14 |
"syscall" |
| 15 | 15 |
"time" |
| 16 | 16 |
|
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/docker/docker/pkg/reexec" |
| 19 | 18 |
"github.com/docker/libnetwork/ns" |
| 20 | 19 |
"github.com/docker/libnetwork/types" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 21 | 21 |
"github.com/vishvananda/netlink" |
| 22 | 22 |
"github.com/vishvananda/netns" |
| 23 | 23 |
) |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
"sync" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/libnetwork/etchosts" |
| 14 | 13 |
"github.com/docker/libnetwork/netlabel" |
| 15 | 14 |
"github.com/docker/libnetwork/osl" |
| 16 | 15 |
"github.com/docker/libnetwork/types" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
// Sandbox provides the control over the network container entity. It is a one to one mapping with the container. |
| ... | ... |
@@ -11,11 +11,11 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"strings" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/libnetwork/etchosts" |
| 16 | 15 |
"github.com/docker/libnetwork/resolvconf" |
| 17 | 16 |
"github.com/docker/libnetwork/resolvconf/dns" |
| 18 | 17 |
"github.com/docker/libnetwork/types" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 19 | 19 |
) |
| 20 | 20 |
|
| 21 | 21 |
const ( |
| ... | ... |
@@ -5,8 +5,8 @@ package libnetwork |
| 5 | 5 |
import ( |
| 6 | 6 |
"net" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/libnetwork/common" |
| 9 |
+ "github.com/sirupsen/logrus" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
func (c *controller) addEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, addService bool, method string) error {
|
| ... | ... |
@@ -14,12 +14,12 @@ import ( |
| 14 | 14 |
"sync" |
| 15 | 15 |
"syscall" |
| 16 | 16 |
|
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/docker/docker/pkg/reexec" |
| 19 | 18 |
"github.com/docker/libnetwork/iptables" |
| 20 | 19 |
"github.com/docker/libnetwork/ipvs" |
| 21 | 20 |
"github.com/docker/libnetwork/ns" |
| 22 | 21 |
"github.com/gogo/protobuf/proto" |
| 22 |
+ "github.com/sirupsen/logrus" |
|
| 23 | 23 |
"github.com/vishvananda/netlink/nl" |
| 24 | 24 |
"github.com/vishvananda/netns" |
| 25 | 25 |
) |
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/libkv/store/boltdb" |
| 9 | 8 |
"github.com/docker/libkv/store/consul" |
| 10 | 9 |
"github.com/docker/libkv/store/etcd" |
| 11 | 10 |
"github.com/docker/libkv/store/zookeeper" |
| 12 | 11 |
"github.com/docker/libnetwork/datastore" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
) |
| 14 | 14 |
|
| 15 | 15 |
func registerKVStores() {
|
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/swarmkit/api" |
| 9 | 8 |
"github.com/docker/swarmkit/api/equality" |
| 10 | 9 |
"github.com/docker/swarmkit/log" |
| 11 | 10 |
"github.com/docker/swarmkit/protobuf/ptypes" |
| 12 | 11 |
"github.com/pkg/errors" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
"golang.org/x/net/context" |
| 14 | 14 |
) |
| 15 | 15 |
|
| ... | ... |
@@ -5,10 +5,10 @@ import ( |
| 5 | 5 |
"sync" |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 | 8 |
"github.com/docker/swarmkit/api" |
| 10 | 9 |
"github.com/docker/swarmkit/connectionbroker" |
| 11 | 10 |
"github.com/docker/swarmkit/log" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
"google.golang.org/grpc" |
| 14 | 14 |
"google.golang.org/grpc/codes" |
| ... | ... |
@@ -3,12 +3,12 @@ package agent |
| 3 | 3 |
import ( |
| 4 | 4 |
"sync" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/boltdb/bolt" |
| 8 | 7 |
"github.com/docker/swarmkit/agent/exec" |
| 9 | 8 |
"github.com/docker/swarmkit/api" |
| 10 | 9 |
"github.com/docker/swarmkit/log" |
| 11 | 10 |
"github.com/docker/swarmkit/watch" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
) |
| 14 | 14 |
|
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"sync" |
| 13 | 13 |
"time" |
| 14 | 14 |
|
| 15 |
- "github.com/Sirupsen/logrus" |
|
| 16 | 15 |
cfconfig "github.com/cloudflare/cfssl/config" |
| 17 | 16 |
events "github.com/docker/go-events" |
| 18 | 17 |
"github.com/docker/swarmkit/api" |
| ... | ... |
@@ -22,6 +21,7 @@ import ( |
| 22 | 22 |
"github.com/docker/swarmkit/watch" |
| 23 | 23 |
"github.com/opencontainers/go-digest" |
| 24 | 24 |
"github.com/pkg/errors" |
| 25 |
+ "github.com/sirupsen/logrus" |
|
| 25 | 26 |
"google.golang.org/grpc/credentials" |
| 26 | 27 |
|
| 27 | 28 |
"golang.org/x/net/context" |
| ... | ... |
@@ -14,13 +14,13 @@ import ( |
| 14 | 14 |
"sync" |
| 15 | 15 |
"time" |
| 16 | 16 |
|
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/cloudflare/cfssl/api" |
| 19 | 18 |
"github.com/cloudflare/cfssl/config" |
| 20 | 19 |
"github.com/cloudflare/cfssl/csr" |
| 21 | 20 |
"github.com/cloudflare/cfssl/signer" |
| 22 | 21 |
"github.com/docker/swarmkit/log" |
| 23 | 22 |
"github.com/pkg/errors" |
| 23 |
+ "github.com/sirupsen/logrus" |
|
| 24 | 24 |
"golang.org/x/net/context" |
| 25 | 25 |
"golang.org/x/net/context/ctxhttp" |
| 26 | 26 |
) |
| ... | ... |
@@ -4,11 +4,11 @@ import ( |
| 4 | 4 |
"sync" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/go-events" |
| 9 | 8 |
"github.com/docker/swarmkit/connectionbroker" |
| 10 | 9 |
"github.com/docker/swarmkit/log" |
| 11 | 10 |
"github.com/pkg/errors" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
) |
| 14 | 14 |
|
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"sync" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/Sirupsen/logrus" |
|
| 11 | 10 |
"github.com/docker/swarmkit/api" |
| 12 | 11 |
"github.com/docker/swarmkit/api/equality" |
| 13 | 12 |
"github.com/docker/swarmkit/identity" |
| ... | ... |
@@ -15,6 +14,7 @@ import ( |
| 15 | 15 |
"github.com/docker/swarmkit/manager/state/store" |
| 16 | 16 |
gogotypes "github.com/gogo/protobuf/types" |
| 17 | 17 |
"github.com/pkg/errors" |
| 18 |
+ "github.com/sirupsen/logrus" |
|
| 18 | 19 |
"golang.org/x/net/context" |
| 19 | 20 |
"google.golang.org/grpc" |
| 20 | 21 |
"google.golang.org/grpc/codes" |
| ... | ... |
@@ -4,11 +4,11 @@ import ( |
| 4 | 4 |
"bytes" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/swarmkit/api" |
| 9 | 8 |
"github.com/docker/swarmkit/identity" |
| 10 | 9 |
"github.com/docker/swarmkit/log" |
| 11 | 10 |
"github.com/docker/swarmkit/manager/state/store" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
"google.golang.org/grpc" |
| 14 | 14 |
"google.golang.org/grpc/codes" |
| ... | ... |
@@ -4,12 +4,12 @@ import ( |
| 4 | 4 |
"crypto/subtle" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 | 7 |
"github.com/docker/swarmkit/api" |
| 9 | 8 |
"github.com/docker/swarmkit/api/validation" |
| 10 | 9 |
"github.com/docker/swarmkit/identity" |
| 11 | 10 |
"github.com/docker/swarmkit/log" |
| 12 | 11 |
"github.com/docker/swarmkit/manager/state/store" |
| 12 |
+ "github.com/sirupsen/logrus" |
|
| 13 | 13 |
"golang.org/x/net/context" |
| 14 | 14 |
"google.golang.org/grpc" |
| 15 | 15 |
"google.golang.org/grpc/codes" |
| ... | ... |
@@ -3,12 +3,12 @@ package dispatcher |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/docker/swarmkit/api" |
| 8 | 7 |
"github.com/docker/swarmkit/api/equality" |
| 9 | 8 |
"github.com/docker/swarmkit/api/validation" |
| 10 | 9 |
"github.com/docker/swarmkit/manager/drivers" |
| 11 | 10 |
"github.com/docker/swarmkit/manager/state/store" |
| 11 |
+ "github.com/sirupsen/logrus" |
|
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// Used as a key in tasksUsingDependency and changes. Only using the |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
"google.golang.org/grpc/codes" |
| 12 | 12 |
"google.golang.org/grpc/transport" |
| 13 | 13 |
|
| 14 |
- "github.com/Sirupsen/logrus" |
|
| 15 | 14 |
"github.com/docker/go-events" |
| 16 | 15 |
"github.com/docker/swarmkit/api" |
| 17 | 16 |
"github.com/docker/swarmkit/api/equality" |
| ... | ... |
@@ -23,6 +22,7 @@ import ( |
| 23 | 23 |
"github.com/docker/swarmkit/watch" |
| 24 | 24 |
gogotypes "github.com/gogo/protobuf/types" |
| 25 | 25 |
"github.com/pkg/errors" |
| 26 |
+ "github.com/sirupsen/logrus" |
|
| 26 | 27 |
"golang.org/x/net/context" |
| 27 | 28 |
) |
| 28 | 29 |
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"google.golang.org/grpc" |
| 10 | 10 |
"google.golang.org/grpc/codes" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/docker/go-events" |
| 14 | 13 |
"github.com/docker/swarmkit/api" |
| 15 | 14 |
"github.com/docker/swarmkit/ca" |
| ... | ... |
@@ -17,6 +16,7 @@ import ( |
| 17 | 17 |
"github.com/docker/swarmkit/log" |
| 18 | 18 |
"github.com/docker/swarmkit/manager/state/store" |
| 19 | 19 |
"github.com/docker/swarmkit/watch" |
| 20 |
+ "github.com/sirupsen/logrus" |
|
| 20 | 21 |
"golang.org/x/net/context" |
| 21 | 22 |
) |
| 22 | 23 |
|
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
"syscall" |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 |
- "github.com/Sirupsen/logrus" |
|
| 17 | 16 |
"github.com/cloudflare/cfssl/helpers" |
| 18 | 17 |
"github.com/docker/docker/pkg/plugingetter" |
| 19 | 18 |
"github.com/docker/go-events" |
| ... | ... |
@@ -45,6 +44,7 @@ import ( |
| 45 | 45 |
gogotypes "github.com/gogo/protobuf/types" |
| 46 | 46 |
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" |
| 47 | 47 |
"github.com/pkg/errors" |
| 48 |
+ "github.com/sirupsen/logrus" |
|
| 48 | 49 |
"golang.org/x/net/context" |
| 49 | 50 |
"google.golang.org/grpc" |
| 50 | 51 |
"google.golang.org/grpc/credentials" |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"sync/atomic" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/coreos/etcd/pkg/idutil" |
| 14 | 13 |
"github.com/coreos/etcd/raft" |
| 15 | 14 |
"github.com/coreos/etcd/raft/raftpb" |
| ... | ... |
@@ -28,6 +27,7 @@ import ( |
| 28 | 28 |
"github.com/gogo/protobuf/proto" |
| 29 | 29 |
"github.com/pivotal-golang/clock" |
| 30 | 30 |
"github.com/pkg/errors" |
| 31 |
+ "github.com/sirupsen/logrus" |
|
| 31 | 32 |
"golang.org/x/net/context" |
| 32 | 33 |
"golang.org/x/time/rate" |
| 33 | 34 |
"google.golang.org/grpc" |
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"sync" |
| 15 | 15 |
"time" |
| 16 | 16 |
|
| 17 |
- "github.com/Sirupsen/logrus" |
|
| 18 | 17 |
"github.com/boltdb/bolt" |
| 19 | 18 |
"github.com/docker/docker/pkg/plugingetter" |
| 20 | 19 |
metrics "github.com/docker/go-metrics" |
| ... | ... |
@@ -31,6 +30,7 @@ import ( |
| 31 | 31 |
"github.com/docker/swarmkit/xnet" |
| 32 | 32 |
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" |
| 33 | 33 |
"github.com/pkg/errors" |
| 34 |
+ "github.com/sirupsen/logrus" |
|
| 34 | 35 |
"golang.org/x/net/context" |
| 35 | 36 |
"google.golang.org/grpc" |
| 36 | 37 |
"google.golang.org/grpc/codes" |
| 15 | 15 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+The MIT License (MIT) |
|
| 1 |
+ |
|
| 2 |
+Copyright (c) 2014 Simon Eskildsen |
|
| 3 |
+ |
|
| 4 |
+Permission is hereby granted, free of charge, to any person obtaining a copy |
|
| 5 |
+of this software and associated documentation files (the "Software"), to deal |
|
| 6 |
+in the Software without restriction, including without limitation the rights |
|
| 7 |
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
| 8 |
+copies of the Software, and to permit persons to whom the Software is |
|
| 9 |
+furnished to do so, subject to the following conditions: |
|
| 10 |
+ |
|
| 11 |
+The above copyright notice and this permission notice shall be included in |
|
| 12 |
+all copies or substantial portions of the Software. |
|
| 13 |
+ |
|
| 14 |
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 15 |
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 16 |
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
| 17 |
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 18 |
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
| 19 |
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
| 20 |
+THE SOFTWARE. |
| 0 | 21 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,504 @@ |
| 0 |
+# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [](https://travis-ci.org/sirupsen/logrus) [](https://godoc.org/github.com/sirupsen/logrus) |
|
| 1 |
+ |
|
| 2 |
+Logrus is a structured logger for Go (golang), completely API compatible with |
|
| 3 |
+the standard library logger. [Godoc][godoc]. |
|
| 4 |
+ |
|
| 5 |
+**Seeing weird case-sensitive problems?** It's in the past been possible to |
|
| 6 |
+import Logrus as both upper- and lower-case. Due to the Go package environment, |
|
| 7 |
+this caused issues in the community and we needed a standard. Some environments |
|
| 8 |
+experienced problems with the upper-case variant, so the lower-case was decided. |
|
| 9 |
+Everything using `logrus` will need to use the lower-case: |
|
| 10 |
+`github.com/sirupsen/logrus`. Any package that isn't, should be changed. |
|
| 11 |
+ |
|
| 12 |
+To fix Glide, see [these |
|
| 13 |
+comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437). |
|
| 14 |
+For an in-depth explanation of the casing issue, see [this |
|
| 15 |
+comment](https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276). |
|
| 16 |
+ |
|
| 17 |
+**Are you interested in assisting in maintaining Logrus?** Currently I have a |
|
| 18 |
+lot of obligations, and I am unable to provide Logrus with the maintainership it |
|
| 19 |
+needs. If you'd like to help, please reach out to me at `simon at author's |
|
| 20 |
+username dot com`. |
|
| 21 |
+ |
|
| 22 |
+Nicely color-coded in development (when a TTY is attached, otherwise just |
|
| 23 |
+plain text): |
|
| 24 |
+ |
|
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
+With `log.SetFormatter(&log.JSONFormatter{})`, for easy parsing by logstash
|
|
| 28 |
+or Splunk: |
|
| 29 |
+ |
|
| 30 |
+```json |
|
| 31 |
+{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
|
|
| 32 |
+ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"} |
|
| 33 |
+ |
|
| 34 |
+{"level":"warning","msg":"The group's number increased tremendously!",
|
|
| 35 |
+"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"} |
|
| 36 |
+ |
|
| 37 |
+{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
|
|
| 38 |
+"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"} |
|
| 39 |
+ |
|
| 40 |
+{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
|
|
| 41 |
+"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"} |
|
| 42 |
+ |
|
| 43 |
+{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
|
|
| 44 |
+"time":"2014-03-10 19:57:38.562543128 -0400 EDT"} |
|
| 45 |
+``` |
|
| 46 |
+ |
|
| 47 |
+With the default `log.SetFormatter(&log.TextFormatter{})` when a TTY is not
|
|
| 48 |
+attached, the output is compatible with the |
|
| 49 |
+[logfmt](http://godoc.org/github.com/kr/logfmt) format: |
|
| 50 |
+ |
|
| 51 |
+```text |
|
| 52 |
+time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8 |
|
| 53 |
+time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10 |
|
| 54 |
+time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true |
|
| 55 |
+time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4 |
|
| 56 |
+time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 |
|
| 57 |
+time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
|
|
| 58 |
+exit status 1 |
|
| 59 |
+``` |
|
| 60 |
+ |
|
| 61 |
+#### Case-sensitivity |
|
| 62 |
+ |
|
| 63 |
+The organization's name was changed to lower-case--and this will not be changed |
|
| 64 |
+back. If you are getting import conflicts due to case sensitivity, please use |
|
| 65 |
+the lower-case import: `github.com/sirupsen/logrus`. |
|
| 66 |
+ |
|
| 67 |
+#### Example |
|
| 68 |
+ |
|
| 69 |
+The simplest way to use Logrus is simply the package-level exported logger: |
|
| 70 |
+ |
|
| 71 |
+```go |
|
| 72 |
+package main |
|
| 73 |
+ |
|
| 74 |
+import ( |
|
| 75 |
+ log "github.com/sirupsen/logrus" |
|
| 76 |
+) |
|
| 77 |
+ |
|
| 78 |
+func main() {
|
|
| 79 |
+ log.WithFields(log.Fields{
|
|
| 80 |
+ "animal": "walrus", |
|
| 81 |
+ }).Info("A walrus appears")
|
|
| 82 |
+} |
|
| 83 |
+``` |
|
| 84 |
+ |
|
| 85 |
+Note that it's completely api-compatible with the stdlib logger, so you can |
|
| 86 |
+replace your `log` imports everywhere with `log "github.com/sirupsen/logrus"` |
|
| 87 |
+and you'll now have the flexibility of Logrus. You can customize it all you |
|
| 88 |
+want: |
|
| 89 |
+ |
|
| 90 |
+```go |
|
| 91 |
+package main |
|
| 92 |
+ |
|
| 93 |
+import ( |
|
| 94 |
+ "os" |
|
| 95 |
+ log "github.com/sirupsen/logrus" |
|
| 96 |
+) |
|
| 97 |
+ |
|
| 98 |
+func init() {
|
|
| 99 |
+ // Log as JSON instead of the default ASCII formatter. |
|
| 100 |
+ log.SetFormatter(&log.JSONFormatter{})
|
|
| 101 |
+ |
|
| 102 |
+ // Output to stdout instead of the default stderr |
|
| 103 |
+ // Can be any io.Writer, see below for File example |
|
| 104 |
+ log.SetOutput(os.Stdout) |
|
| 105 |
+ |
|
| 106 |
+ // Only log the warning severity or above. |
|
| 107 |
+ log.SetLevel(log.WarnLevel) |
|
| 108 |
+} |
|
| 109 |
+ |
|
| 110 |
+func main() {
|
|
| 111 |
+ log.WithFields(log.Fields{
|
|
| 112 |
+ "animal": "walrus", |
|
| 113 |
+ "size": 10, |
|
| 114 |
+ }).Info("A group of walrus emerges from the ocean")
|
|
| 115 |
+ |
|
| 116 |
+ log.WithFields(log.Fields{
|
|
| 117 |
+ "omg": true, |
|
| 118 |
+ "number": 122, |
|
| 119 |
+ }).Warn("The group's number increased tremendously!")
|
|
| 120 |
+ |
|
| 121 |
+ log.WithFields(log.Fields{
|
|
| 122 |
+ "omg": true, |
|
| 123 |
+ "number": 100, |
|
| 124 |
+ }).Fatal("The ice breaks!")
|
|
| 125 |
+ |
|
| 126 |
+ // A common pattern is to re-use fields between logging statements by re-using |
|
| 127 |
+ // the logrus.Entry returned from WithFields() |
|
| 128 |
+ contextLogger := log.WithFields(log.Fields{
|
|
| 129 |
+ "common": "this is a common field", |
|
| 130 |
+ "other": "I also should be logged always", |
|
| 131 |
+ }) |
|
| 132 |
+ |
|
| 133 |
+ contextLogger.Info("I'll be logged with common and other field")
|
|
| 134 |
+ contextLogger.Info("Me too")
|
|
| 135 |
+} |
|
| 136 |
+``` |
|
| 137 |
+ |
|
| 138 |
+For more advanced usage such as logging to multiple locations from the same |
|
| 139 |
+application, you can also create an instance of the `logrus` Logger: |
|
| 140 |
+ |
|
| 141 |
+```go |
|
| 142 |
+package main |
|
| 143 |
+ |
|
| 144 |
+import ( |
|
| 145 |
+ "os" |
|
| 146 |
+ "github.com/sirupsen/logrus" |
|
| 147 |
+) |
|
| 148 |
+ |
|
| 149 |
+// Create a new instance of the logger. You can have any number of instances. |
|
| 150 |
+var log = logrus.New() |
|
| 151 |
+ |
|
| 152 |
+func main() {
|
|
| 153 |
+ // The API for setting attributes is a little different than the package level |
|
| 154 |
+ // exported logger. See Godoc. |
|
| 155 |
+ log.Out = os.Stdout |
|
| 156 |
+ |
|
| 157 |
+ // You could set this to any `io.Writer` such as a file |
|
| 158 |
+ // file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY, 0666)
|
|
| 159 |
+ // if err == nil {
|
|
| 160 |
+ // log.Out = file |
|
| 161 |
+ // } else {
|
|
| 162 |
+ // log.Info("Failed to log to file, using default stderr")
|
|
| 163 |
+ // } |
|
| 164 |
+ |
|
| 165 |
+ log.WithFields(logrus.Fields{
|
|
| 166 |
+ "animal": "walrus", |
|
| 167 |
+ "size": 10, |
|
| 168 |
+ }).Info("A group of walrus emerges from the ocean")
|
|
| 169 |
+} |
|
| 170 |
+``` |
|
| 171 |
+ |
|
| 172 |
+#### Fields |
|
| 173 |
+ |
|
| 174 |
+Logrus encourages careful, structured logging through logging fields instead of |
|
| 175 |
+long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
|
|
| 176 |
+to send event %s to topic %s with key %d")`, you should log the much more |
|
| 177 |
+discoverable: |
|
| 178 |
+ |
|
| 179 |
+```go |
|
| 180 |
+log.WithFields(log.Fields{
|
|
| 181 |
+ "event": event, |
|
| 182 |
+ "topic": topic, |
|
| 183 |
+ "key": key, |
|
| 184 |
+}).Fatal("Failed to send event")
|
|
| 185 |
+``` |
|
| 186 |
+ |
|
| 187 |
+We've found this API forces you to think about logging in a way that produces |
|
| 188 |
+much more useful logging messages. We've been in countless situations where just |
|
| 189 |
+a single added field to a log statement that was already there would've saved us |
|
| 190 |
+hours. The `WithFields` call is optional. |
|
| 191 |
+ |
|
| 192 |
+In general, with Logrus using any of the `printf`-family functions should be |
|
| 193 |
+seen as a hint you should add a field, however, you can still use the |
|
| 194 |
+`printf`-family functions with Logrus. |
|
| 195 |
+ |
|
| 196 |
+#### Default Fields |
|
| 197 |
+ |
|
| 198 |
+Often it's helpful to have fields _always_ attached to log statements in an |
|
| 199 |
+application or parts of one. For example, you may want to always log the |
|
| 200 |
+`request_id` and `user_ip` in the context of a request. Instead of writing |
|
| 201 |
+`log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})` on
|
|
| 202 |
+every line, you can create a `logrus.Entry` to pass around instead: |
|
| 203 |
+ |
|
| 204 |
+```go |
|
| 205 |
+requestLogger := log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})
|
|
| 206 |
+requestLogger.Info("something happened on that request") # will log request_id and user_ip
|
|
| 207 |
+requestLogger.Warn("something not great happened")
|
|
| 208 |
+``` |
|
| 209 |
+ |
|
| 210 |
+#### Hooks |
|
| 211 |
+ |
|
| 212 |
+You can add hooks for logging levels. For example to send errors to an exception |
|
| 213 |
+tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to |
|
| 214 |
+multiple places simultaneously, e.g. syslog. |
|
| 215 |
+ |
|
| 216 |
+Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in |
|
| 217 |
+`init`: |
|
| 218 |
+ |
|
| 219 |
+```go |
|
| 220 |
+import ( |
|
| 221 |
+ log "github.com/sirupsen/logrus" |
|
| 222 |
+ "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake" |
|
| 223 |
+ logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" |
|
| 224 |
+ "log/syslog" |
|
| 225 |
+) |
|
| 226 |
+ |
|
| 227 |
+func init() {
|
|
| 228 |
+ |
|
| 229 |
+ // Use the Airbrake hook to report errors that have Error severity or above to |
|
| 230 |
+ // an exception tracker. You can create custom hooks, see the Hooks section. |
|
| 231 |
+ log.AddHook(airbrake.NewHook(123, "xyz", "production")) |
|
| 232 |
+ |
|
| 233 |
+ hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
|
|
| 234 |
+ if err != nil {
|
|
| 235 |
+ log.Error("Unable to connect to local syslog daemon")
|
|
| 236 |
+ } else {
|
|
| 237 |
+ log.AddHook(hook) |
|
| 238 |
+ } |
|
| 239 |
+} |
|
| 240 |
+``` |
|
| 241 |
+Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md). |
|
| 242 |
+ |
|
| 243 |
+| Hook | Description | |
|
| 244 |
+| ----- | ----------- | |
|
| 245 |
+| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. | |
|
| 246 |
+| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. | |
|
| 247 |
+| [Amazon Kinesis](https://github.com/evalphobia/logrus_kinesis) | Hook for logging to [Amazon Kinesis](https://aws.amazon.com/kinesis/) | |
|
| 248 |
+| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) | |
|
| 249 |
+| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | |
|
| 250 |
+| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | |
|
| 251 |
+| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) | |
|
| 252 |
+| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch| |
|
| 253 |
+| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/) |
|
| 254 |
+| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | |
|
| 255 |
+| [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) | |
|
| 256 |
+| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | |
|
| 257 |
+| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | |
|
| 258 |
+| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | |
|
| 259 |
+| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | |
|
| 260 |
+| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) | |
|
| 261 |
+| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | |
|
| 262 |
+| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka | |
|
| 263 |
+| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | |
|
| 264 |
+| [Logentries](https://github.com/jcftang/logentriesrus) | Hook for logging to [Logentries](https://logentries.com/) | |
|
| 265 |
+| [Logentrus](https://github.com/puddingfactory/logentrus) | Hook for logging to [Logentries](https://logentries.com/) | |
|
| 266 |
+| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) | |
|
| 267 |
+| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | |
|
| 268 |
+| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) | |
|
| 269 |
+| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | |
|
| 270 |
+| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) | |
|
| 271 |
+| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | |
|
| 272 |
+| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) | |
|
| 273 |
+| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | |
|
| 274 |
+| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. | |
|
| 275 |
+| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) | |
|
| 276 |
+| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) | |
|
| 277 |
+| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) | |
|
| 278 |
+| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) | |
|
| 279 |
+| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar | |
|
| 280 |
+| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)| |
|
| 281 |
+| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. | |
|
| 282 |
+| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | |
|
| 283 |
+| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) | |
|
| 284 |
+| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| |
|
| 285 |
+| [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. | |
|
| 286 |
+| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. | |
|
| 287 |
+| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) | |
|
| 288 |
+| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | |
|
| 289 |
+| [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 | |
|
| 290 |
+| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) | |
|
| 291 |
+ |
|
| 292 |
+#### Level logging |
|
| 293 |
+ |
|
| 294 |
+Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic. |
|
| 295 |
+ |
|
| 296 |
+```go |
|
| 297 |
+log.Debug("Useful debugging information.")
|
|
| 298 |
+log.Info("Something noteworthy happened!")
|
|
| 299 |
+log.Warn("You should probably take a look at this.")
|
|
| 300 |
+log.Error("Something failed but I'm not quitting.")
|
|
| 301 |
+// Calls os.Exit(1) after logging |
|
| 302 |
+log.Fatal("Bye.")
|
|
| 303 |
+// Calls panic() after logging |
|
| 304 |
+log.Panic("I'm bailing.")
|
|
| 305 |
+``` |
|
| 306 |
+ |
|
| 307 |
+You can set the logging level on a `Logger`, then it will only log entries with |
|
| 308 |
+that severity or anything above it: |
|
| 309 |
+ |
|
| 310 |
+```go |
|
| 311 |
+// Will log anything that is info or above (warn, error, fatal, panic). Default. |
|
| 312 |
+log.SetLevel(log.InfoLevel) |
|
| 313 |
+``` |
|
| 314 |
+ |
|
| 315 |
+It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose |
|
| 316 |
+environment if your application has that. |
|
| 317 |
+ |
|
| 318 |
+#### Entries |
|
| 319 |
+ |
|
| 320 |
+Besides the fields added with `WithField` or `WithFields` some fields are |
|
| 321 |
+automatically added to all logging events: |
|
| 322 |
+ |
|
| 323 |
+1. `time`. The timestamp when the entry was created. |
|
| 324 |
+2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
|
|
| 325 |
+ the `AddFields` call. E.g. `Failed to send event.` |
|
| 326 |
+3. `level`. The logging level. E.g. `info`. |
|
| 327 |
+ |
|
| 328 |
+#### Environments |
|
| 329 |
+ |
|
| 330 |
+Logrus has no notion of environment. |
|
| 331 |
+ |
|
| 332 |
+If you wish for hooks and formatters to only be used in specific environments, |
|
| 333 |
+you should handle that yourself. For example, if your application has a global |
|
| 334 |
+variable `Environment`, which is a string representation of the environment you |
|
| 335 |
+could do: |
|
| 336 |
+ |
|
| 337 |
+```go |
|
| 338 |
+import ( |
|
| 339 |
+ log "github.com/sirupsen/logrus" |
|
| 340 |
+) |
|
| 341 |
+ |
|
| 342 |
+init() {
|
|
| 343 |
+ // do something here to set environment depending on an environment variable |
|
| 344 |
+ // or command-line flag |
|
| 345 |
+ if Environment == "production" {
|
|
| 346 |
+ log.SetFormatter(&log.JSONFormatter{})
|
|
| 347 |
+ } else {
|
|
| 348 |
+ // The TextFormatter is default, you don't actually have to do this. |
|
| 349 |
+ log.SetFormatter(&log.TextFormatter{})
|
|
| 350 |
+ } |
|
| 351 |
+} |
|
| 352 |
+``` |
|
| 353 |
+ |
|
| 354 |
+This configuration is how `logrus` was intended to be used, but JSON in |
|
| 355 |
+production is mostly only useful if you do log aggregation with tools like |
|
| 356 |
+Splunk or Logstash. |
|
| 357 |
+ |
|
| 358 |
+#### Formatters |
|
| 359 |
+ |
|
| 360 |
+The built-in logging formatters are: |
|
| 361 |
+ |
|
| 362 |
+* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise |
|
| 363 |
+ without colors. |
|
| 364 |
+ * *Note:* to force colored output when there is no TTY, set the `ForceColors` |
|
| 365 |
+ field to `true`. To force no colored output even if there is a TTY set the |
|
| 366 |
+ `DisableColors` field to `true`. For Windows, see |
|
| 367 |
+ [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable). |
|
| 368 |
+ * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter). |
|
| 369 |
+* `logrus.JSONFormatter`. Logs fields as JSON. |
|
| 370 |
+ * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter). |
|
| 371 |
+ |
|
| 372 |
+Third party logging formatters: |
|
| 373 |
+ |
|
| 374 |
+* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. |
|
| 375 |
+* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. |
|
| 376 |
+* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. |
|
| 377 |
+ |
|
| 378 |
+You can define your formatter by implementing the `Formatter` interface, |
|
| 379 |
+requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a |
|
| 380 |
+`Fields` type (`map[string]interface{}`) with all your fields as well as the
|
|
| 381 |
+default ones (see Entries section above): |
|
| 382 |
+ |
|
| 383 |
+```go |
|
| 384 |
+type MyJSONFormatter struct {
|
|
| 385 |
+} |
|
| 386 |
+ |
|
| 387 |
+log.SetFormatter(new(MyJSONFormatter)) |
|
| 388 |
+ |
|
| 389 |
+func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
|
|
| 390 |
+ // Note this doesn't include Time, Level and Message which are available on |
|
| 391 |
+ // the Entry. Consult `godoc` on information about those fields or read the |
|
| 392 |
+ // source of the official loggers. |
|
| 393 |
+ serialized, err := json.Marshal(entry.Data) |
|
| 394 |
+ if err != nil {
|
|
| 395 |
+ return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
|
| 396 |
+ } |
|
| 397 |
+ return append(serialized, '\n'), nil |
|
| 398 |
+} |
|
| 399 |
+``` |
|
| 400 |
+ |
|
| 401 |
+#### Logger as an `io.Writer` |
|
| 402 |
+ |
|
| 403 |
+Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it. |
|
| 404 |
+ |
|
| 405 |
+```go |
|
| 406 |
+w := logger.Writer() |
|
| 407 |
+defer w.Close() |
|
| 408 |
+ |
|
| 409 |
+srv := http.Server{
|
|
| 410 |
+ // create a stdlib log.Logger that writes to |
|
| 411 |
+ // logrus.Logger. |
|
| 412 |
+ ErrorLog: log.New(w, "", 0), |
|
| 413 |
+} |
|
| 414 |
+``` |
|
| 415 |
+ |
|
| 416 |
+Each line written to that writer will be printed the usual way, using formatters |
|
| 417 |
+and hooks. The level for those entries is `info`. |
|
| 418 |
+ |
|
| 419 |
+This means that we can override the standard library logger easily: |
|
| 420 |
+ |
|
| 421 |
+```go |
|
| 422 |
+logger := logrus.New() |
|
| 423 |
+logger.Formatter = &logrus.JSONFormatter{}
|
|
| 424 |
+ |
|
| 425 |
+// Use logrus for standard log output |
|
| 426 |
+// Note that `log` here references stdlib's log |
|
| 427 |
+// Not logrus imported under the name `log`. |
|
| 428 |
+log.SetOutput(logger.Writer()) |
|
| 429 |
+``` |
|
| 430 |
+ |
|
| 431 |
+#### Rotation |
|
| 432 |
+ |
|
| 433 |
+Log rotation is not provided with Logrus. Log rotation should be done by an |
|
| 434 |
+external program (like `logrotate(8)`) that can compress and delete old log |
|
| 435 |
+entries. It should not be a feature of the application-level logger. |
|
| 436 |
+ |
|
| 437 |
+#### Tools |
|
| 438 |
+ |
|
| 439 |
+| Tool | Description | |
|
| 440 |
+| ---- | ----------- | |
|
| 441 |
+|[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.| |
|
| 442 |
+|[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) | |
|
| 443 |
+ |
|
| 444 |
+#### Testing |
|
| 445 |
+ |
|
| 446 |
+Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides: |
|
| 447 |
+ |
|
| 448 |
+* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just add the `test` hook |
|
| 449 |
+* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any): |
|
| 450 |
+ |
|
| 451 |
+```go |
|
| 452 |
+import( |
|
| 453 |
+ "github.com/sirupsen/logrus" |
|
| 454 |
+ "github.com/sirupsen/logrus/hooks/test" |
|
| 455 |
+ "github.com/stretchr/testify/assert" |
|
| 456 |
+ "testing" |
|
| 457 |
+) |
|
| 458 |
+ |
|
| 459 |
+func TestSomething(t*testing.T){
|
|
| 460 |
+ logger, hook := test.NewNullLogger() |
|
| 461 |
+ logger.Error("Helloerror")
|
|
| 462 |
+ |
|
| 463 |
+ assert.Equal(t, 1, len(hook.Entries)) |
|
| 464 |
+ assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level) |
|
| 465 |
+ assert.Equal(t, "Helloerror", hook.LastEntry().Message) |
|
| 466 |
+ |
|
| 467 |
+ hook.Reset() |
|
| 468 |
+ assert.Nil(t, hook.LastEntry()) |
|
| 469 |
+} |
|
| 470 |
+``` |
|
| 471 |
+ |
|
| 472 |
+#### Fatal handlers |
|
| 473 |
+ |
|
| 474 |
+Logrus can register one or more functions that will be called when any `fatal` |
|
| 475 |
+level message is logged. The registered handlers will be executed before |
|
| 476 |
+logrus performs a `os.Exit(1)`. This behavior may be helpful if callers need |
|
| 477 |
+to gracefully shutdown. Unlike a `panic("Something went wrong...")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted.
|
|
| 478 |
+ |
|
| 479 |
+``` |
|
| 480 |
+... |
|
| 481 |
+handler := func() {
|
|
| 482 |
+ // gracefully shutdown something... |
|
| 483 |
+} |
|
| 484 |
+logrus.RegisterExitHandler(handler) |
|
| 485 |
+... |
|
| 486 |
+``` |
|
| 487 |
+ |
|
| 488 |
+#### Thread safety |
|
| 489 |
+ |
|
| 490 |
+By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs. |
|
| 491 |
+If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking. |
|
| 492 |
+ |
|
| 493 |
+Situation when locking is not needed includes: |
|
| 494 |
+ |
|
| 495 |
+* You have no hooks registered, or hooks calling is already thread-safe. |
|
| 496 |
+ |
|
| 497 |
+* Writing to logger.Out is already thread-safe, for example: |
|
| 498 |
+ |
|
| 499 |
+ 1) logger.Out is protected by locks. |
|
| 500 |
+ |
|
| 501 |
+ 2) logger.Out is a os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allow multi-thread/multi-process writing) |
|
| 502 |
+ |
|
| 503 |
+ (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/) |
| 0 | 504 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,64 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+// The following code was sourced and modified from the |
|
| 3 |
+// https://github.com/tebeka/atexit package governed by the following license: |
|
| 4 |
+// |
|
| 5 |
+// Copyright (c) 2012 Miki Tebeka <miki.tebeka@gmail.com>. |
|
| 6 |
+// |
|
| 7 |
+// Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
| 8 |
+// this software and associated documentation files (the "Software"), to deal in |
|
| 9 |
+// the Software without restriction, including without limitation the rights to |
|
| 10 |
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
| 11 |
+// the Software, and to permit persons to whom the Software is furnished to do so, |
|
| 12 |
+// subject to the following conditions: |
|
| 13 |
+// |
|
| 14 |
+// The above copyright notice and this permission notice shall be included in all |
|
| 15 |
+// copies or substantial portions of the Software. |
|
| 16 |
+// |
|
| 17 |
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 18 |
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
| 19 |
+// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
| 20 |
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
| 21 |
+// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
| 22 |
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
| 23 |
+ |
|
| 24 |
+import ( |
|
| 25 |
+ "fmt" |
|
| 26 |
+ "os" |
|
| 27 |
+) |
|
| 28 |
+ |
|
| 29 |
+var handlers = []func(){}
|
|
| 30 |
+ |
|
| 31 |
+func runHandler(handler func()) {
|
|
| 32 |
+ defer func() {
|
|
| 33 |
+ if err := recover(); err != nil {
|
|
| 34 |
+ fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) |
|
| 35 |
+ } |
|
| 36 |
+ }() |
|
| 37 |
+ |
|
| 38 |
+ handler() |
|
| 39 |
+} |
|
| 40 |
+ |
|
| 41 |
+func runHandlers() {
|
|
| 42 |
+ for _, handler := range handlers {
|
|
| 43 |
+ runHandler(handler) |
|
| 44 |
+ } |
|
| 45 |
+} |
|
| 46 |
+ |
|
| 47 |
+// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) |
|
| 48 |
+func Exit(code int) {
|
|
| 49 |
+ runHandlers() |
|
| 50 |
+ os.Exit(code) |
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke |
|
| 54 |
+// all handlers. The handlers will also be invoked when any Fatal log entry is |
|
| 55 |
+// made. |
|
| 56 |
+// |
|
| 57 |
+// This method is useful when a caller wishes to use logrus to log a fatal |
|
| 58 |
+// message but also needs to gracefully shutdown. An example usecase could be |
|
| 59 |
+// closing database connections, or sending a alert that the application is |
|
| 60 |
+// closing. |
|
| 61 |
+func RegisterExitHandler(handler func()) {
|
|
| 62 |
+ handlers = append(handlers, handler) |
|
| 63 |
+} |
| 0 | 64 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,26 @@ |
| 0 |
+/* |
|
| 1 |
+Package logrus is a structured logger for Go, completely API compatible with the standard library logger. |
|
| 2 |
+ |
|
| 3 |
+ |
|
| 4 |
+The simplest way to use Logrus is simply the package-level exported logger: |
|
| 5 |
+ |
|
| 6 |
+ package main |
|
| 7 |
+ |
|
| 8 |
+ import ( |
|
| 9 |
+ log "github.com/sirupsen/logrus" |
|
| 10 |
+ ) |
|
| 11 |
+ |
|
| 12 |
+ func main() {
|
|
| 13 |
+ log.WithFields(log.Fields{
|
|
| 14 |
+ "animal": "walrus", |
|
| 15 |
+ "number": 1, |
|
| 16 |
+ "size": 10, |
|
| 17 |
+ }).Info("A walrus appears")
|
|
| 18 |
+ } |
|
| 19 |
+ |
|
| 20 |
+Output: |
|
| 21 |
+ time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 |
|
| 22 |
+ |
|
| 23 |
+For a full guide visit https://github.com/sirupsen/logrus |
|
| 24 |
+*/ |
|
| 25 |
+package logrus |
| 0 | 26 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,275 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "bytes" |
|
| 4 |
+ "fmt" |
|
| 5 |
+ "os" |
|
| 6 |
+ "sync" |
|
| 7 |
+ "time" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+var bufferPool *sync.Pool |
|
| 11 |
+ |
|
| 12 |
+func init() {
|
|
| 13 |
+ bufferPool = &sync.Pool{
|
|
| 14 |
+ New: func() interface{} {
|
|
| 15 |
+ return new(bytes.Buffer) |
|
| 16 |
+ }, |
|
| 17 |
+ } |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+// Defines the key when adding errors using WithError. |
|
| 21 |
+var ErrorKey = "error" |
|
| 22 |
+ |
|
| 23 |
+// An entry is the final or intermediate Logrus logging entry. It contains all |
|
| 24 |
+// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
|
|
| 25 |
+// Warn, Error, Fatal or Panic is called on it. These objects can be reused and |
|
| 26 |
+// passed around as much as you wish to avoid field duplication. |
|
| 27 |
+type Entry struct {
|
|
| 28 |
+ Logger *Logger |
|
| 29 |
+ |
|
| 30 |
+ // Contains all the fields set by the user. |
|
| 31 |
+ Data Fields |
|
| 32 |
+ |
|
| 33 |
+ // Time at which the log entry was created |
|
| 34 |
+ Time time.Time |
|
| 35 |
+ |
|
| 36 |
+ // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic |
|
| 37 |
+ Level Level |
|
| 38 |
+ |
|
| 39 |
+ // Message passed to Debug, Info, Warn, Error, Fatal or Panic |
|
| 40 |
+ Message string |
|
| 41 |
+ |
|
| 42 |
+ // When formatter is called in entry.log(), an Buffer may be set to entry |
|
| 43 |
+ Buffer *bytes.Buffer |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+func NewEntry(logger *Logger) *Entry {
|
|
| 47 |
+ return &Entry{
|
|
| 48 |
+ Logger: logger, |
|
| 49 |
+ // Default is three fields, give a little extra room |
|
| 50 |
+ Data: make(Fields, 5), |
|
| 51 |
+ } |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+// Returns the string representation from the reader and ultimately the |
|
| 55 |
+// formatter. |
|
| 56 |
+func (entry *Entry) String() (string, error) {
|
|
| 57 |
+ serialized, err := entry.Logger.Formatter.Format(entry) |
|
| 58 |
+ if err != nil {
|
|
| 59 |
+ return "", err |
|
| 60 |
+ } |
|
| 61 |
+ str := string(serialized) |
|
| 62 |
+ return str, nil |
|
| 63 |
+} |
|
| 64 |
+ |
|
| 65 |
+// Add an error as single field (using the key defined in ErrorKey) to the Entry. |
|
| 66 |
+func (entry *Entry) WithError(err error) *Entry {
|
|
| 67 |
+ return entry.WithField(ErrorKey, err) |
|
| 68 |
+} |
|
| 69 |
+ |
|
| 70 |
+// Add a single field to the Entry. |
|
| 71 |
+func (entry *Entry) WithField(key string, value interface{}) *Entry {
|
|
| 72 |
+ return entry.WithFields(Fields{key: value})
|
|
| 73 |
+} |
|
| 74 |
+ |
|
| 75 |
+// Add a map of fields to the Entry. |
|
| 76 |
+func (entry *Entry) WithFields(fields Fields) *Entry {
|
|
| 77 |
+ data := make(Fields, len(entry.Data)+len(fields)) |
|
| 78 |
+ for k, v := range entry.Data {
|
|
| 79 |
+ data[k] = v |
|
| 80 |
+ } |
|
| 81 |
+ for k, v := range fields {
|
|
| 82 |
+ data[k] = v |
|
| 83 |
+ } |
|
| 84 |
+ return &Entry{Logger: entry.Logger, Data: data}
|
|
| 85 |
+} |
|
| 86 |
+ |
|
| 87 |
+// This function is not declared with a pointer value because otherwise |
|
| 88 |
+// race conditions will occur when using multiple goroutines |
|
| 89 |
+func (entry Entry) log(level Level, msg string) {
|
|
| 90 |
+ var buffer *bytes.Buffer |
|
| 91 |
+ entry.Time = time.Now() |
|
| 92 |
+ entry.Level = level |
|
| 93 |
+ entry.Message = msg |
|
| 94 |
+ |
|
| 95 |
+ if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
|
|
| 96 |
+ entry.Logger.mu.Lock() |
|
| 97 |
+ fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) |
|
| 98 |
+ entry.Logger.mu.Unlock() |
|
| 99 |
+ } |
|
| 100 |
+ buffer = bufferPool.Get().(*bytes.Buffer) |
|
| 101 |
+ buffer.Reset() |
|
| 102 |
+ defer bufferPool.Put(buffer) |
|
| 103 |
+ entry.Buffer = buffer |
|
| 104 |
+ serialized, err := entry.Logger.Formatter.Format(&entry) |
|
| 105 |
+ entry.Buffer = nil |
|
| 106 |
+ if err != nil {
|
|
| 107 |
+ entry.Logger.mu.Lock() |
|
| 108 |
+ fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err) |
|
| 109 |
+ entry.Logger.mu.Unlock() |
|
| 110 |
+ } else {
|
|
| 111 |
+ entry.Logger.mu.Lock() |
|
| 112 |
+ _, err = entry.Logger.Out.Write(serialized) |
|
| 113 |
+ if err != nil {
|
|
| 114 |
+ fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) |
|
| 115 |
+ } |
|
| 116 |
+ entry.Logger.mu.Unlock() |
|
| 117 |
+ } |
|
| 118 |
+ |
|
| 119 |
+ // To avoid Entry#log() returning a value that only would make sense for |
|
| 120 |
+ // panic() to use in Entry#Panic(), we avoid the allocation by checking |
|
| 121 |
+ // directly here. |
|
| 122 |
+ if level <= PanicLevel {
|
|
| 123 |
+ panic(&entry) |
|
| 124 |
+ } |
|
| 125 |
+} |
|
| 126 |
+ |
|
| 127 |
+func (entry *Entry) Debug(args ...interface{}) {
|
|
| 128 |
+ if entry.Logger.level() >= DebugLevel {
|
|
| 129 |
+ entry.log(DebugLevel, fmt.Sprint(args...)) |
|
| 130 |
+ } |
|
| 131 |
+} |
|
| 132 |
+ |
|
| 133 |
+func (entry *Entry) Print(args ...interface{}) {
|
|
| 134 |
+ entry.Info(args...) |
|
| 135 |
+} |
|
| 136 |
+ |
|
| 137 |
+func (entry *Entry) Info(args ...interface{}) {
|
|
| 138 |
+ if entry.Logger.level() >= InfoLevel {
|
|
| 139 |
+ entry.log(InfoLevel, fmt.Sprint(args...)) |
|
| 140 |
+ } |
|
| 141 |
+} |
|
| 142 |
+ |
|
| 143 |
+func (entry *Entry) Warn(args ...interface{}) {
|
|
| 144 |
+ if entry.Logger.level() >= WarnLevel {
|
|
| 145 |
+ entry.log(WarnLevel, fmt.Sprint(args...)) |
|
| 146 |
+ } |
|
| 147 |
+} |
|
| 148 |
+ |
|
| 149 |
+func (entry *Entry) Warning(args ...interface{}) {
|
|
| 150 |
+ entry.Warn(args...) |
|
| 151 |
+} |
|
| 152 |
+ |
|
| 153 |
+func (entry *Entry) Error(args ...interface{}) {
|
|
| 154 |
+ if entry.Logger.level() >= ErrorLevel {
|
|
| 155 |
+ entry.log(ErrorLevel, fmt.Sprint(args...)) |
|
| 156 |
+ } |
|
| 157 |
+} |
|
| 158 |
+ |
|
| 159 |
+func (entry *Entry) Fatal(args ...interface{}) {
|
|
| 160 |
+ if entry.Logger.level() >= FatalLevel {
|
|
| 161 |
+ entry.log(FatalLevel, fmt.Sprint(args...)) |
|
| 162 |
+ } |
|
| 163 |
+ Exit(1) |
|
| 164 |
+} |
|
| 165 |
+ |
|
| 166 |
+func (entry *Entry) Panic(args ...interface{}) {
|
|
| 167 |
+ if entry.Logger.level() >= PanicLevel {
|
|
| 168 |
+ entry.log(PanicLevel, fmt.Sprint(args...)) |
|
| 169 |
+ } |
|
| 170 |
+ panic(fmt.Sprint(args...)) |
|
| 171 |
+} |
|
| 172 |
+ |
|
| 173 |
+// Entry Printf family functions |
|
| 174 |
+ |
|
| 175 |
+func (entry *Entry) Debugf(format string, args ...interface{}) {
|
|
| 176 |
+ if entry.Logger.level() >= DebugLevel {
|
|
| 177 |
+ entry.Debug(fmt.Sprintf(format, args...)) |
|
| 178 |
+ } |
|
| 179 |
+} |
|
| 180 |
+ |
|
| 181 |
+func (entry *Entry) Infof(format string, args ...interface{}) {
|
|
| 182 |
+ if entry.Logger.level() >= InfoLevel {
|
|
| 183 |
+ entry.Info(fmt.Sprintf(format, args...)) |
|
| 184 |
+ } |
|
| 185 |
+} |
|
| 186 |
+ |
|
| 187 |
+func (entry *Entry) Printf(format string, args ...interface{}) {
|
|
| 188 |
+ entry.Infof(format, args...) |
|
| 189 |
+} |
|
| 190 |
+ |
|
| 191 |
+func (entry *Entry) Warnf(format string, args ...interface{}) {
|
|
| 192 |
+ if entry.Logger.level() >= WarnLevel {
|
|
| 193 |
+ entry.Warn(fmt.Sprintf(format, args...)) |
|
| 194 |
+ } |
|
| 195 |
+} |
|
| 196 |
+ |
|
| 197 |
+func (entry *Entry) Warningf(format string, args ...interface{}) {
|
|
| 198 |
+ entry.Warnf(format, args...) |
|
| 199 |
+} |
|
| 200 |
+ |
|
| 201 |
+func (entry *Entry) Errorf(format string, args ...interface{}) {
|
|
| 202 |
+ if entry.Logger.level() >= ErrorLevel {
|
|
| 203 |
+ entry.Error(fmt.Sprintf(format, args...)) |
|
| 204 |
+ } |
|
| 205 |
+} |
|
| 206 |
+ |
|
| 207 |
+func (entry *Entry) Fatalf(format string, args ...interface{}) {
|
|
| 208 |
+ if entry.Logger.level() >= FatalLevel {
|
|
| 209 |
+ entry.Fatal(fmt.Sprintf(format, args...)) |
|
| 210 |
+ } |
|
| 211 |
+ Exit(1) |
|
| 212 |
+} |
|
| 213 |
+ |
|
| 214 |
+func (entry *Entry) Panicf(format string, args ...interface{}) {
|
|
| 215 |
+ if entry.Logger.level() >= PanicLevel {
|
|
| 216 |
+ entry.Panic(fmt.Sprintf(format, args...)) |
|
| 217 |
+ } |
|
| 218 |
+} |
|
| 219 |
+ |
|
| 220 |
+// Entry Println family functions |
|
| 221 |
+ |
|
| 222 |
+func (entry *Entry) Debugln(args ...interface{}) {
|
|
| 223 |
+ if entry.Logger.level() >= DebugLevel {
|
|
| 224 |
+ entry.Debug(entry.sprintlnn(args...)) |
|
| 225 |
+ } |
|
| 226 |
+} |
|
| 227 |
+ |
|
| 228 |
+func (entry *Entry) Infoln(args ...interface{}) {
|
|
| 229 |
+ if entry.Logger.level() >= InfoLevel {
|
|
| 230 |
+ entry.Info(entry.sprintlnn(args...)) |
|
| 231 |
+ } |
|
| 232 |
+} |
|
| 233 |
+ |
|
| 234 |
+func (entry *Entry) Println(args ...interface{}) {
|
|
| 235 |
+ entry.Infoln(args...) |
|
| 236 |
+} |
|
| 237 |
+ |
|
| 238 |
+func (entry *Entry) Warnln(args ...interface{}) {
|
|
| 239 |
+ if entry.Logger.level() >= WarnLevel {
|
|
| 240 |
+ entry.Warn(entry.sprintlnn(args...)) |
|
| 241 |
+ } |
|
| 242 |
+} |
|
| 243 |
+ |
|
| 244 |
+func (entry *Entry) Warningln(args ...interface{}) {
|
|
| 245 |
+ entry.Warnln(args...) |
|
| 246 |
+} |
|
| 247 |
+ |
|
| 248 |
+func (entry *Entry) Errorln(args ...interface{}) {
|
|
| 249 |
+ if entry.Logger.level() >= ErrorLevel {
|
|
| 250 |
+ entry.Error(entry.sprintlnn(args...)) |
|
| 251 |
+ } |
|
| 252 |
+} |
|
| 253 |
+ |
|
| 254 |
+func (entry *Entry) Fatalln(args ...interface{}) {
|
|
| 255 |
+ if entry.Logger.level() >= FatalLevel {
|
|
| 256 |
+ entry.Fatal(entry.sprintlnn(args...)) |
|
| 257 |
+ } |
|
| 258 |
+ Exit(1) |
|
| 259 |
+} |
|
| 260 |
+ |
|
| 261 |
+func (entry *Entry) Panicln(args ...interface{}) {
|
|
| 262 |
+ if entry.Logger.level() >= PanicLevel {
|
|
| 263 |
+ entry.Panic(entry.sprintlnn(args...)) |
|
| 264 |
+ } |
|
| 265 |
+} |
|
| 266 |
+ |
|
| 267 |
+// Sprintlnn => Sprint no newline. This is to get the behavior of how |
|
| 268 |
+// fmt.Sprintln where spaces are always added between operands, regardless of |
|
| 269 |
+// their type. Instead of vendoring the Sprintln implementation to spare a |
|
| 270 |
+// string allocation, we do the simplest thing. |
|
| 271 |
+func (entry *Entry) sprintlnn(args ...interface{}) string {
|
|
| 272 |
+ msg := fmt.Sprintln(args...) |
|
| 273 |
+ return msg[:len(msg)-1] |
|
| 274 |
+} |
| 0 | 275 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,193 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "io" |
|
| 4 |
+) |
|
| 5 |
+ |
|
| 6 |
+var ( |
|
| 7 |
+ // std is the name of the standard logger in stdlib `log` |
|
| 8 |
+ std = New() |
|
| 9 |
+) |
|
| 10 |
+ |
|
| 11 |
+func StandardLogger() *Logger {
|
|
| 12 |
+ return std |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 15 |
+// SetOutput sets the standard logger output. |
|
| 16 |
+func SetOutput(out io.Writer) {
|
|
| 17 |
+ std.mu.Lock() |
|
| 18 |
+ defer std.mu.Unlock() |
|
| 19 |
+ std.Out = out |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 22 |
+// SetFormatter sets the standard logger formatter. |
|
| 23 |
+func SetFormatter(formatter Formatter) {
|
|
| 24 |
+ std.mu.Lock() |
|
| 25 |
+ defer std.mu.Unlock() |
|
| 26 |
+ std.Formatter = formatter |
|
| 27 |
+} |
|
| 28 |
+ |
|
| 29 |
+// SetLevel sets the standard logger level. |
|
| 30 |
+func SetLevel(level Level) {
|
|
| 31 |
+ std.mu.Lock() |
|
| 32 |
+ defer std.mu.Unlock() |
|
| 33 |
+ std.setLevel(level) |
|
| 34 |
+} |
|
| 35 |
+ |
|
| 36 |
+// GetLevel returns the standard logger level. |
|
| 37 |
+func GetLevel() Level {
|
|
| 38 |
+ std.mu.Lock() |
|
| 39 |
+ defer std.mu.Unlock() |
|
| 40 |
+ return std.level() |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+// AddHook adds a hook to the standard logger hooks. |
|
| 44 |
+func AddHook(hook Hook) {
|
|
| 45 |
+ std.mu.Lock() |
|
| 46 |
+ defer std.mu.Unlock() |
|
| 47 |
+ std.Hooks.Add(hook) |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 50 |
+// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. |
|
| 51 |
+func WithError(err error) *Entry {
|
|
| 52 |
+ return std.WithField(ErrorKey, err) |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+// WithField creates an entry from the standard logger and adds a field to |
|
| 56 |
+// it. If you want multiple fields, use `WithFields`. |
|
| 57 |
+// |
|
| 58 |
+// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal |
|
| 59 |
+// or Panic on the Entry it returns. |
|
| 60 |
+func WithField(key string, value interface{}) *Entry {
|
|
| 61 |
+ return std.WithField(key, value) |
|
| 62 |
+} |
|
| 63 |
+ |
|
| 64 |
+// WithFields creates an entry from the standard logger and adds multiple |
|
| 65 |
+// fields to it. This is simply a helper for `WithField`, invoking it |
|
| 66 |
+// once for each field. |
|
| 67 |
+// |
|
| 68 |
+// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal |
|
| 69 |
+// or Panic on the Entry it returns. |
|
| 70 |
+func WithFields(fields Fields) *Entry {
|
|
| 71 |
+ return std.WithFields(fields) |
|
| 72 |
+} |
|
| 73 |
+ |
|
| 74 |
+// Debug logs a message at level Debug on the standard logger. |
|
| 75 |
+func Debug(args ...interface{}) {
|
|
| 76 |
+ std.Debug(args...) |
|
| 77 |
+} |
|
| 78 |
+ |
|
| 79 |
+// Print logs a message at level Info on the standard logger. |
|
| 80 |
+func Print(args ...interface{}) {
|
|
| 81 |
+ std.Print(args...) |
|
| 82 |
+} |
|
| 83 |
+ |
|
| 84 |
+// Info logs a message at level Info on the standard logger. |
|
| 85 |
+func Info(args ...interface{}) {
|
|
| 86 |
+ std.Info(args...) |
|
| 87 |
+} |
|
| 88 |
+ |
|
| 89 |
+// Warn logs a message at level Warn on the standard logger. |
|
| 90 |
+func Warn(args ...interface{}) {
|
|
| 91 |
+ std.Warn(args...) |
|
| 92 |
+} |
|
| 93 |
+ |
|
| 94 |
+// Warning logs a message at level Warn on the standard logger. |
|
| 95 |
+func Warning(args ...interface{}) {
|
|
| 96 |
+ std.Warning(args...) |
|
| 97 |
+} |
|
| 98 |
+ |
|
| 99 |
+// Error logs a message at level Error on the standard logger. |
|
| 100 |
+func Error(args ...interface{}) {
|
|
| 101 |
+ std.Error(args...) |
|
| 102 |
+} |
|
| 103 |
+ |
|
| 104 |
+// Panic logs a message at level Panic on the standard logger. |
|
| 105 |
+func Panic(args ...interface{}) {
|
|
| 106 |
+ std.Panic(args...) |
|
| 107 |
+} |
|
| 108 |
+ |
|
| 109 |
+// Fatal logs a message at level Fatal on the standard logger. |
|
| 110 |
+func Fatal(args ...interface{}) {
|
|
| 111 |
+ std.Fatal(args...) |
|
| 112 |
+} |
|
| 113 |
+ |
|
| 114 |
+// Debugf logs a message at level Debug on the standard logger. |
|
| 115 |
+func Debugf(format string, args ...interface{}) {
|
|
| 116 |
+ std.Debugf(format, args...) |
|
| 117 |
+} |
|
| 118 |
+ |
|
| 119 |
+// Printf logs a message at level Info on the standard logger. |
|
| 120 |
+func Printf(format string, args ...interface{}) {
|
|
| 121 |
+ std.Printf(format, args...) |
|
| 122 |
+} |
|
| 123 |
+ |
|
| 124 |
+// Infof logs a message at level Info on the standard logger. |
|
| 125 |
+func Infof(format string, args ...interface{}) {
|
|
| 126 |
+ std.Infof(format, args...) |
|
| 127 |
+} |
|
| 128 |
+ |
|
| 129 |
+// Warnf logs a message at level Warn on the standard logger. |
|
| 130 |
+func Warnf(format string, args ...interface{}) {
|
|
| 131 |
+ std.Warnf(format, args...) |
|
| 132 |
+} |
|
| 133 |
+ |
|
| 134 |
+// Warningf logs a message at level Warn on the standard logger. |
|
| 135 |
+func Warningf(format string, args ...interface{}) {
|
|
| 136 |
+ std.Warningf(format, args...) |
|
| 137 |
+} |
|
| 138 |
+ |
|
| 139 |
+// Errorf logs a message at level Error on the standard logger. |
|
| 140 |
+func Errorf(format string, args ...interface{}) {
|
|
| 141 |
+ std.Errorf(format, args...) |
|
| 142 |
+} |
|
| 143 |
+ |
|
| 144 |
+// Panicf logs a message at level Panic on the standard logger. |
|
| 145 |
+func Panicf(format string, args ...interface{}) {
|
|
| 146 |
+ std.Panicf(format, args...) |
|
| 147 |
+} |
|
| 148 |
+ |
|
| 149 |
+// Fatalf logs a message at level Fatal on the standard logger. |
|
| 150 |
+func Fatalf(format string, args ...interface{}) {
|
|
| 151 |
+ std.Fatalf(format, args...) |
|
| 152 |
+} |
|
| 153 |
+ |
|
| 154 |
+// Debugln logs a message at level Debug on the standard logger. |
|
| 155 |
+func Debugln(args ...interface{}) {
|
|
| 156 |
+ std.Debugln(args...) |
|
| 157 |
+} |
|
| 158 |
+ |
|
| 159 |
+// Println logs a message at level Info on the standard logger. |
|
| 160 |
+func Println(args ...interface{}) {
|
|
| 161 |
+ std.Println(args...) |
|
| 162 |
+} |
|
| 163 |
+ |
|
| 164 |
+// Infoln logs a message at level Info on the standard logger. |
|
| 165 |
+func Infoln(args ...interface{}) {
|
|
| 166 |
+ std.Infoln(args...) |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 169 |
+// Warnln logs a message at level Warn on the standard logger. |
|
| 170 |
+func Warnln(args ...interface{}) {
|
|
| 171 |
+ std.Warnln(args...) |
|
| 172 |
+} |
|
| 173 |
+ |
|
| 174 |
+// Warningln logs a message at level Warn on the standard logger. |
|
| 175 |
+func Warningln(args ...interface{}) {
|
|
| 176 |
+ std.Warningln(args...) |
|
| 177 |
+} |
|
| 178 |
+ |
|
| 179 |
+// Errorln logs a message at level Error on the standard logger. |
|
| 180 |
+func Errorln(args ...interface{}) {
|
|
| 181 |
+ std.Errorln(args...) |
|
| 182 |
+} |
|
| 183 |
+ |
|
| 184 |
+// Panicln logs a message at level Panic on the standard logger. |
|
| 185 |
+func Panicln(args ...interface{}) {
|
|
| 186 |
+ std.Panicln(args...) |
|
| 187 |
+} |
|
| 188 |
+ |
|
| 189 |
+// Fatalln logs a message at level Fatal on the standard logger. |
|
| 190 |
+func Fatalln(args ...interface{}) {
|
|
| 191 |
+ std.Fatalln(args...) |
|
| 192 |
+} |
| 0 | 193 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,45 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import "time" |
|
| 3 |
+ |
|
| 4 |
+const DefaultTimestampFormat = time.RFC3339 |
|
| 5 |
+ |
|
| 6 |
+// The Formatter interface is used to implement a custom Formatter. It takes an |
|
| 7 |
+// `Entry`. It exposes all the fields, including the default ones: |
|
| 8 |
+// |
|
| 9 |
+// * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. |
|
| 10 |
+// * `entry.Data["time"]`. The timestamp. |
|
| 11 |
+// * `entry.Data["level"]. The level the entry was logged at. |
|
| 12 |
+// |
|
| 13 |
+// Any additional fields added with `WithField` or `WithFields` are also in |
|
| 14 |
+// `entry.Data`. Format is expected to return an array of bytes which are then |
|
| 15 |
+// logged to `logger.Out`. |
|
| 16 |
+type Formatter interface {
|
|
| 17 |
+ Format(*Entry) ([]byte, error) |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+// This is to not silently overwrite `time`, `msg` and `level` fields when |
|
| 21 |
+// dumping it. If this code wasn't there doing: |
|
| 22 |
+// |
|
| 23 |
+// logrus.WithField("level", 1).Info("hello")
|
|
| 24 |
+// |
|
| 25 |
+// Would just silently drop the user provided level. Instead with this code |
|
| 26 |
+// it'll logged as: |
|
| 27 |
+// |
|
| 28 |
+// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
|
|
| 29 |
+// |
|
| 30 |
+// It's not exported because it's still using Data in an opinionated way. It's to |
|
| 31 |
+// avoid code duplication between the two default formatters. |
|
| 32 |
+func prefixFieldClashes(data Fields) {
|
|
| 33 |
+ if t, ok := data["time"]; ok {
|
|
| 34 |
+ data["fields.time"] = t |
|
| 35 |
+ } |
|
| 36 |
+ |
|
| 37 |
+ if m, ok := data["msg"]; ok {
|
|
| 38 |
+ data["fields.msg"] = m |
|
| 39 |
+ } |
|
| 40 |
+ |
|
| 41 |
+ if l, ok := data["level"]; ok {
|
|
| 42 |
+ data["fields.level"] = l |
|
| 43 |
+ } |
|
| 44 |
+} |
| 0 | 45 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,34 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+// A hook to be fired when logging on the logging levels returned from |
|
| 3 |
+// `Levels()` on your implementation of the interface. Note that this is not |
|
| 4 |
+// fired in a goroutine or a channel with workers, you should handle such |
|
| 5 |
+// functionality yourself if your call is non-blocking and you don't wish for |
|
| 6 |
+// the logging calls for levels returned from `Levels()` to block. |
|
| 7 |
+type Hook interface {
|
|
| 8 |
+ Levels() []Level |
|
| 9 |
+ Fire(*Entry) error |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+// Internal type for storing the hooks on a logger instance. |
|
| 13 |
+type LevelHooks map[Level][]Hook |
|
| 14 |
+ |
|
| 15 |
+// Add a hook to an instance of logger. This is called with |
|
| 16 |
+// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. |
|
| 17 |
+func (hooks LevelHooks) Add(hook Hook) {
|
|
| 18 |
+ for _, level := range hook.Levels() {
|
|
| 19 |
+ hooks[level] = append(hooks[level], hook) |
|
| 20 |
+ } |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+// Fire all the hooks for the passed level. Used by `entry.log` to fire |
|
| 24 |
+// appropriate hooks for a log entry. |
|
| 25 |
+func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
|
|
| 26 |
+ for _, hook := range hooks[level] {
|
|
| 27 |
+ if err := hook.Fire(entry); err != nil {
|
|
| 28 |
+ return err |
|
| 29 |
+ } |
|
| 30 |
+ } |
|
| 31 |
+ |
|
| 32 |
+ return nil |
|
| 33 |
+} |
| 0 | 34 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,74 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "encoding/json" |
|
| 4 |
+ "fmt" |
|
| 5 |
+) |
|
| 6 |
+ |
|
| 7 |
+type fieldKey string |
|
| 8 |
+type FieldMap map[fieldKey]string |
|
| 9 |
+ |
|
| 10 |
+const ( |
|
| 11 |
+ FieldKeyMsg = "msg" |
|
| 12 |
+ FieldKeyLevel = "level" |
|
| 13 |
+ FieldKeyTime = "time" |
|
| 14 |
+) |
|
| 15 |
+ |
|
| 16 |
+func (f FieldMap) resolve(key fieldKey) string {
|
|
| 17 |
+ if k, ok := f[key]; ok {
|
|
| 18 |
+ return k |
|
| 19 |
+ } |
|
| 20 |
+ |
|
| 21 |
+ return string(key) |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+type JSONFormatter struct {
|
|
| 25 |
+ // TimestampFormat sets the format used for marshaling timestamps. |
|
| 26 |
+ TimestampFormat string |
|
| 27 |
+ |
|
| 28 |
+ // DisableTimestamp allows disabling automatic timestamps in output |
|
| 29 |
+ DisableTimestamp bool |
|
| 30 |
+ |
|
| 31 |
+ // FieldMap allows users to customize the names of keys for various fields. |
|
| 32 |
+ // As an example: |
|
| 33 |
+ // formatter := &JSONFormatter{
|
|
| 34 |
+ // FieldMap: FieldMap{
|
|
| 35 |
+ // FieldKeyTime: "@timestamp", |
|
| 36 |
+ // FieldKeyLevel: "@level", |
|
| 37 |
+ // FieldKeyMsg: "@message", |
|
| 38 |
+ // }, |
|
| 39 |
+ // } |
|
| 40 |
+ FieldMap FieldMap |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
|
|
| 44 |
+ data := make(Fields, len(entry.Data)+3) |
|
| 45 |
+ for k, v := range entry.Data {
|
|
| 46 |
+ switch v := v.(type) {
|
|
| 47 |
+ case error: |
|
| 48 |
+ // Otherwise errors are ignored by `encoding/json` |
|
| 49 |
+ // https://github.com/sirupsen/logrus/issues/137 |
|
| 50 |
+ data[k] = v.Error() |
|
| 51 |
+ default: |
|
| 52 |
+ data[k] = v |
|
| 53 |
+ } |
|
| 54 |
+ } |
|
| 55 |
+ prefixFieldClashes(data) |
|
| 56 |
+ |
|
| 57 |
+ timestampFormat := f.TimestampFormat |
|
| 58 |
+ if timestampFormat == "" {
|
|
| 59 |
+ timestampFormat = DefaultTimestampFormat |
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ if !f.DisableTimestamp {
|
|
| 63 |
+ data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) |
|
| 64 |
+ } |
|
| 65 |
+ data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message |
|
| 66 |
+ data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() |
|
| 67 |
+ |
|
| 68 |
+ serialized, err := json.Marshal(data) |
|
| 69 |
+ if err != nil {
|
|
| 70 |
+ return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
|
| 71 |
+ } |
|
| 72 |
+ return append(serialized, '\n'), nil |
|
| 73 |
+} |
| 0 | 74 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,317 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "io" |
|
| 4 |
+ "os" |
|
| 5 |
+ "sync" |
|
| 6 |
+ "sync/atomic" |
|
| 7 |
+) |
|
| 8 |
+ |
|
| 9 |
+type Logger struct {
|
|
| 10 |
+ // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a |
|
| 11 |
+ // file, or leave it default which is `os.Stderr`. You can also set this to |
|
| 12 |
+ // something more adventorous, such as logging to Kafka. |
|
| 13 |
+ Out io.Writer |
|
| 14 |
+ // Hooks for the logger instance. These allow firing events based on logging |
|
| 15 |
+ // levels and log entries. For example, to send errors to an error tracking |
|
| 16 |
+ // service, log to StatsD or dump the core on fatal errors. |
|
| 17 |
+ Hooks LevelHooks |
|
| 18 |
+ // All log entries pass through the formatter before logged to Out. The |
|
| 19 |
+ // included formatters are `TextFormatter` and `JSONFormatter` for which |
|
| 20 |
+ // TextFormatter is the default. In development (when a TTY is attached) it |
|
| 21 |
+ // logs with colors, but to a file it wouldn't. You can easily implement your |
|
| 22 |
+ // own that implements the `Formatter` interface, see the `README` or included |
|
| 23 |
+ // formatters for examples. |
|
| 24 |
+ Formatter Formatter |
|
| 25 |
+ // The logging level the logger should log at. This is typically (and defaults |
|
| 26 |
+ // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be |
|
| 27 |
+ // logged. `logrus.Debug` is useful in |
|
| 28 |
+ Level Level |
|
| 29 |
+ // Used to sync writing to the log. Locking is enabled by Default |
|
| 30 |
+ mu MutexWrap |
|
| 31 |
+ // Reusable empty entry |
|
| 32 |
+ entryPool sync.Pool |
|
| 33 |
+} |
|
| 34 |
+ |
|
| 35 |
+type MutexWrap struct {
|
|
| 36 |
+ lock sync.Mutex |
|
| 37 |
+ disabled bool |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+func (mw *MutexWrap) Lock() {
|
|
| 41 |
+ if !mw.disabled {
|
|
| 42 |
+ mw.lock.Lock() |
|
| 43 |
+ } |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+func (mw *MutexWrap) Unlock() {
|
|
| 47 |
+ if !mw.disabled {
|
|
| 48 |
+ mw.lock.Unlock() |
|
| 49 |
+ } |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 52 |
+func (mw *MutexWrap) Disable() {
|
|
| 53 |
+ mw.disabled = true |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+// Creates a new logger. Configuration should be set by changing `Formatter`, |
|
| 57 |
+// `Out` and `Hooks` directly on the default logger instance. You can also just |
|
| 58 |
+// instantiate your own: |
|
| 59 |
+// |
|
| 60 |
+// var log = &Logger{
|
|
| 61 |
+// Out: os.Stderr, |
|
| 62 |
+// Formatter: new(JSONFormatter), |
|
| 63 |
+// Hooks: make(LevelHooks), |
|
| 64 |
+// Level: logrus.DebugLevel, |
|
| 65 |
+// } |
|
| 66 |
+// |
|
| 67 |
+// It's recommended to make this a global instance called `log`. |
|
| 68 |
+func New() *Logger {
|
|
| 69 |
+ return &Logger{
|
|
| 70 |
+ Out: os.Stderr, |
|
| 71 |
+ Formatter: new(TextFormatter), |
|
| 72 |
+ Hooks: make(LevelHooks), |
|
| 73 |
+ Level: InfoLevel, |
|
| 74 |
+ } |
|
| 75 |
+} |
|
| 76 |
+ |
|
| 77 |
+func (logger *Logger) newEntry() *Entry {
|
|
| 78 |
+ entry, ok := logger.entryPool.Get().(*Entry) |
|
| 79 |
+ if ok {
|
|
| 80 |
+ return entry |
|
| 81 |
+ } |
|
| 82 |
+ return NewEntry(logger) |
|
| 83 |
+} |
|
| 84 |
+ |
|
| 85 |
+func (logger *Logger) releaseEntry(entry *Entry) {
|
|
| 86 |
+ logger.entryPool.Put(entry) |
|
| 87 |
+} |
|
| 88 |
+ |
|
| 89 |
+// Adds a field to the log entry, note that it doesn't log until you call |
|
| 90 |
+// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. |
|
| 91 |
+// If you want multiple fields, use `WithFields`. |
|
| 92 |
+func (logger *Logger) WithField(key string, value interface{}) *Entry {
|
|
| 93 |
+ entry := logger.newEntry() |
|
| 94 |
+ defer logger.releaseEntry(entry) |
|
| 95 |
+ return entry.WithField(key, value) |
|
| 96 |
+} |
|
| 97 |
+ |
|
| 98 |
+// Adds a struct of fields to the log entry. All it does is call `WithField` for |
|
| 99 |
+// each `Field`. |
|
| 100 |
+func (logger *Logger) WithFields(fields Fields) *Entry {
|
|
| 101 |
+ entry := logger.newEntry() |
|
| 102 |
+ defer logger.releaseEntry(entry) |
|
| 103 |
+ return entry.WithFields(fields) |
|
| 104 |
+} |
|
| 105 |
+ |
|
| 106 |
+// Add an error as single field to the log entry. All it does is call |
|
| 107 |
+// `WithError` for the given `error`. |
|
| 108 |
+func (logger *Logger) WithError(err error) *Entry {
|
|
| 109 |
+ entry := logger.newEntry() |
|
| 110 |
+ defer logger.releaseEntry(entry) |
|
| 111 |
+ return entry.WithError(err) |
|
| 112 |
+} |
|
| 113 |
+ |
|
| 114 |
+func (logger *Logger) Debugf(format string, args ...interface{}) {
|
|
| 115 |
+ if logger.level() >= DebugLevel {
|
|
| 116 |
+ entry := logger.newEntry() |
|
| 117 |
+ entry.Debugf(format, args...) |
|
| 118 |
+ logger.releaseEntry(entry) |
|
| 119 |
+ } |
|
| 120 |
+} |
|
| 121 |
+ |
|
| 122 |
+func (logger *Logger) Infof(format string, args ...interface{}) {
|
|
| 123 |
+ if logger.level() >= InfoLevel {
|
|
| 124 |
+ entry := logger.newEntry() |
|
| 125 |
+ entry.Infof(format, args...) |
|
| 126 |
+ logger.releaseEntry(entry) |
|
| 127 |
+ } |
|
| 128 |
+} |
|
| 129 |
+ |
|
| 130 |
+func (logger *Logger) Printf(format string, args ...interface{}) {
|
|
| 131 |
+ entry := logger.newEntry() |
|
| 132 |
+ entry.Printf(format, args...) |
|
| 133 |
+ logger.releaseEntry(entry) |
|
| 134 |
+} |
|
| 135 |
+ |
|
| 136 |
+func (logger *Logger) Warnf(format string, args ...interface{}) {
|
|
| 137 |
+ if logger.level() >= WarnLevel {
|
|
| 138 |
+ entry := logger.newEntry() |
|
| 139 |
+ entry.Warnf(format, args...) |
|
| 140 |
+ logger.releaseEntry(entry) |
|
| 141 |
+ } |
|
| 142 |
+} |
|
| 143 |
+ |
|
| 144 |
+func (logger *Logger) Warningf(format string, args ...interface{}) {
|
|
| 145 |
+ if logger.level() >= WarnLevel {
|
|
| 146 |
+ entry := logger.newEntry() |
|
| 147 |
+ entry.Warnf(format, args...) |
|
| 148 |
+ logger.releaseEntry(entry) |
|
| 149 |
+ } |
|
| 150 |
+} |
|
| 151 |
+ |
|
| 152 |
+func (logger *Logger) Errorf(format string, args ...interface{}) {
|
|
| 153 |
+ if logger.level() >= ErrorLevel {
|
|
| 154 |
+ entry := logger.newEntry() |
|
| 155 |
+ entry.Errorf(format, args...) |
|
| 156 |
+ logger.releaseEntry(entry) |
|
| 157 |
+ } |
|
| 158 |
+} |
|
| 159 |
+ |
|
| 160 |
+func (logger *Logger) Fatalf(format string, args ...interface{}) {
|
|
| 161 |
+ if logger.level() >= FatalLevel {
|
|
| 162 |
+ entry := logger.newEntry() |
|
| 163 |
+ entry.Fatalf(format, args...) |
|
| 164 |
+ logger.releaseEntry(entry) |
|
| 165 |
+ } |
|
| 166 |
+ Exit(1) |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 169 |
+func (logger *Logger) Panicf(format string, args ...interface{}) {
|
|
| 170 |
+ if logger.level() >= PanicLevel {
|
|
| 171 |
+ entry := logger.newEntry() |
|
| 172 |
+ entry.Panicf(format, args...) |
|
| 173 |
+ logger.releaseEntry(entry) |
|
| 174 |
+ } |
|
| 175 |
+} |
|
| 176 |
+ |
|
| 177 |
+func (logger *Logger) Debug(args ...interface{}) {
|
|
| 178 |
+ if logger.level() >= DebugLevel {
|
|
| 179 |
+ entry := logger.newEntry() |
|
| 180 |
+ entry.Debug(args...) |
|
| 181 |
+ logger.releaseEntry(entry) |
|
| 182 |
+ } |
|
| 183 |
+} |
|
| 184 |
+ |
|
| 185 |
+func (logger *Logger) Info(args ...interface{}) {
|
|
| 186 |
+ if logger.level() >= InfoLevel {
|
|
| 187 |
+ entry := logger.newEntry() |
|
| 188 |
+ entry.Info(args...) |
|
| 189 |
+ logger.releaseEntry(entry) |
|
| 190 |
+ } |
|
| 191 |
+} |
|
| 192 |
+ |
|
| 193 |
+func (logger *Logger) Print(args ...interface{}) {
|
|
| 194 |
+ entry := logger.newEntry() |
|
| 195 |
+ entry.Info(args...) |
|
| 196 |
+ logger.releaseEntry(entry) |
|
| 197 |
+} |
|
| 198 |
+ |
|
| 199 |
+func (logger *Logger) Warn(args ...interface{}) {
|
|
| 200 |
+ if logger.level() >= WarnLevel {
|
|
| 201 |
+ entry := logger.newEntry() |
|
| 202 |
+ entry.Warn(args...) |
|
| 203 |
+ logger.releaseEntry(entry) |
|
| 204 |
+ } |
|
| 205 |
+} |
|
| 206 |
+ |
|
| 207 |
+func (logger *Logger) Warning(args ...interface{}) {
|
|
| 208 |
+ if logger.level() >= WarnLevel {
|
|
| 209 |
+ entry := logger.newEntry() |
|
| 210 |
+ entry.Warn(args...) |
|
| 211 |
+ logger.releaseEntry(entry) |
|
| 212 |
+ } |
|
| 213 |
+} |
|
| 214 |
+ |
|
| 215 |
+func (logger *Logger) Error(args ...interface{}) {
|
|
| 216 |
+ if logger.level() >= ErrorLevel {
|
|
| 217 |
+ entry := logger.newEntry() |
|
| 218 |
+ entry.Error(args...) |
|
| 219 |
+ logger.releaseEntry(entry) |
|
| 220 |
+ } |
|
| 221 |
+} |
|
| 222 |
+ |
|
| 223 |
+func (logger *Logger) Fatal(args ...interface{}) {
|
|
| 224 |
+ if logger.level() >= FatalLevel {
|
|
| 225 |
+ entry := logger.newEntry() |
|
| 226 |
+ entry.Fatal(args...) |
|
| 227 |
+ logger.releaseEntry(entry) |
|
| 228 |
+ } |
|
| 229 |
+ Exit(1) |
|
| 230 |
+} |
|
| 231 |
+ |
|
| 232 |
+func (logger *Logger) Panic(args ...interface{}) {
|
|
| 233 |
+ if logger.level() >= PanicLevel {
|
|
| 234 |
+ entry := logger.newEntry() |
|
| 235 |
+ entry.Panic(args...) |
|
| 236 |
+ logger.releaseEntry(entry) |
|
| 237 |
+ } |
|
| 238 |
+} |
|
| 239 |
+ |
|
| 240 |
+func (logger *Logger) Debugln(args ...interface{}) {
|
|
| 241 |
+ if logger.level() >= DebugLevel {
|
|
| 242 |
+ entry := logger.newEntry() |
|
| 243 |
+ entry.Debugln(args...) |
|
| 244 |
+ logger.releaseEntry(entry) |
|
| 245 |
+ } |
|
| 246 |
+} |
|
| 247 |
+ |
|
| 248 |
+func (logger *Logger) Infoln(args ...interface{}) {
|
|
| 249 |
+ if logger.level() >= InfoLevel {
|
|
| 250 |
+ entry := logger.newEntry() |
|
| 251 |
+ entry.Infoln(args...) |
|
| 252 |
+ logger.releaseEntry(entry) |
|
| 253 |
+ } |
|
| 254 |
+} |
|
| 255 |
+ |
|
| 256 |
+func (logger *Logger) Println(args ...interface{}) {
|
|
| 257 |
+ entry := logger.newEntry() |
|
| 258 |
+ entry.Println(args...) |
|
| 259 |
+ logger.releaseEntry(entry) |
|
| 260 |
+} |
|
| 261 |
+ |
|
| 262 |
+func (logger *Logger) Warnln(args ...interface{}) {
|
|
| 263 |
+ if logger.level() >= WarnLevel {
|
|
| 264 |
+ entry := logger.newEntry() |
|
| 265 |
+ entry.Warnln(args...) |
|
| 266 |
+ logger.releaseEntry(entry) |
|
| 267 |
+ } |
|
| 268 |
+} |
|
| 269 |
+ |
|
| 270 |
+func (logger *Logger) Warningln(args ...interface{}) {
|
|
| 271 |
+ if logger.level() >= WarnLevel {
|
|
| 272 |
+ entry := logger.newEntry() |
|
| 273 |
+ entry.Warnln(args...) |
|
| 274 |
+ logger.releaseEntry(entry) |
|
| 275 |
+ } |
|
| 276 |
+} |
|
| 277 |
+ |
|
| 278 |
+func (logger *Logger) Errorln(args ...interface{}) {
|
|
| 279 |
+ if logger.level() >= ErrorLevel {
|
|
| 280 |
+ entry := logger.newEntry() |
|
| 281 |
+ entry.Errorln(args...) |
|
| 282 |
+ logger.releaseEntry(entry) |
|
| 283 |
+ } |
|
| 284 |
+} |
|
| 285 |
+ |
|
| 286 |
+func (logger *Logger) Fatalln(args ...interface{}) {
|
|
| 287 |
+ if logger.level() >= FatalLevel {
|
|
| 288 |
+ entry := logger.newEntry() |
|
| 289 |
+ entry.Fatalln(args...) |
|
| 290 |
+ logger.releaseEntry(entry) |
|
| 291 |
+ } |
|
| 292 |
+ Exit(1) |
|
| 293 |
+} |
|
| 294 |
+ |
|
| 295 |
+func (logger *Logger) Panicln(args ...interface{}) {
|
|
| 296 |
+ if logger.level() >= PanicLevel {
|
|
| 297 |
+ entry := logger.newEntry() |
|
| 298 |
+ entry.Panicln(args...) |
|
| 299 |
+ logger.releaseEntry(entry) |
|
| 300 |
+ } |
|
| 301 |
+} |
|
| 302 |
+ |
|
| 303 |
+//When file is opened with appending mode, it's safe to |
|
| 304 |
+//write concurrently to a file (within 4k message on Linux). |
|
| 305 |
+//In these cases user can choose to disable the lock. |
|
| 306 |
+func (logger *Logger) SetNoLock() {
|
|
| 307 |
+ logger.mu.Disable() |
|
| 308 |
+} |
|
| 309 |
+ |
|
| 310 |
+func (logger *Logger) level() Level {
|
|
| 311 |
+ return Level(atomic.LoadUint32((*uint32)(&logger.Level))) |
|
| 312 |
+} |
|
| 313 |
+ |
|
| 314 |
+func (logger *Logger) setLevel(level Level) {
|
|
| 315 |
+ atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) |
|
| 316 |
+} |
| 0 | 317 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,143 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+ "log" |
|
| 5 |
+ "strings" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+// Fields type, used to pass to `WithFields`. |
|
| 9 |
+type Fields map[string]interface{}
|
|
| 10 |
+ |
|
| 11 |
+// Level type |
|
| 12 |
+type Level uint32 |
|
| 13 |
+ |
|
| 14 |
+// Convert the Level to a string. E.g. PanicLevel becomes "panic". |
|
| 15 |
+func (level Level) String() string {
|
|
| 16 |
+ switch level {
|
|
| 17 |
+ case DebugLevel: |
|
| 18 |
+ return "debug" |
|
| 19 |
+ case InfoLevel: |
|
| 20 |
+ return "info" |
|
| 21 |
+ case WarnLevel: |
|
| 22 |
+ return "warning" |
|
| 23 |
+ case ErrorLevel: |
|
| 24 |
+ return "error" |
|
| 25 |
+ case FatalLevel: |
|
| 26 |
+ return "fatal" |
|
| 27 |
+ case PanicLevel: |
|
| 28 |
+ return "panic" |
|
| 29 |
+ } |
|
| 30 |
+ |
|
| 31 |
+ return "unknown" |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+// ParseLevel takes a string level and returns the Logrus log level constant. |
|
| 35 |
+func ParseLevel(lvl string) (Level, error) {
|
|
| 36 |
+ switch strings.ToLower(lvl) {
|
|
| 37 |
+ case "panic": |
|
| 38 |
+ return PanicLevel, nil |
|
| 39 |
+ case "fatal": |
|
| 40 |
+ return FatalLevel, nil |
|
| 41 |
+ case "error": |
|
| 42 |
+ return ErrorLevel, nil |
|
| 43 |
+ case "warn", "warning": |
|
| 44 |
+ return WarnLevel, nil |
|
| 45 |
+ case "info": |
|
| 46 |
+ return InfoLevel, nil |
|
| 47 |
+ case "debug": |
|
| 48 |
+ return DebugLevel, nil |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ var l Level |
|
| 52 |
+ return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
|
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+// A constant exposing all logging levels |
|
| 56 |
+var AllLevels = []Level{
|
|
| 57 |
+ PanicLevel, |
|
| 58 |
+ FatalLevel, |
|
| 59 |
+ ErrorLevel, |
|
| 60 |
+ WarnLevel, |
|
| 61 |
+ InfoLevel, |
|
| 62 |
+ DebugLevel, |
|
| 63 |
+} |
|
| 64 |
+ |
|
| 65 |
+// These are the different logging levels. You can set the logging level to log |
|
| 66 |
+// on your instance of logger, obtained with `logrus.New()`. |
|
| 67 |
+const ( |
|
| 68 |
+ // PanicLevel level, highest level of severity. Logs and then calls panic with the |
|
| 69 |
+ // message passed to Debug, Info, ... |
|
| 70 |
+ PanicLevel Level = iota |
|
| 71 |
+ // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the |
|
| 72 |
+ // logging level is set to Panic. |
|
| 73 |
+ FatalLevel |
|
| 74 |
+ // ErrorLevel level. Logs. Used for errors that should definitely be noted. |
|
| 75 |
+ // Commonly used for hooks to send errors to an error tracking service. |
|
| 76 |
+ ErrorLevel |
|
| 77 |
+ // WarnLevel level. Non-critical entries that deserve eyes. |
|
| 78 |
+ WarnLevel |
|
| 79 |
+ // InfoLevel level. General operational entries about what's going on inside the |
|
| 80 |
+ // application. |
|
| 81 |
+ InfoLevel |
|
| 82 |
+ // DebugLevel level. Usually only enabled when debugging. Very verbose logging. |
|
| 83 |
+ DebugLevel |
|
| 84 |
+) |
|
| 85 |
+ |
|
| 86 |
+// Won't compile if StdLogger can't be realized by a log.Logger |
|
| 87 |
+var ( |
|
| 88 |
+ _ StdLogger = &log.Logger{}
|
|
| 89 |
+ _ StdLogger = &Entry{}
|
|
| 90 |
+ _ StdLogger = &Logger{}
|
|
| 91 |
+) |
|
| 92 |
+ |
|
| 93 |
+// StdLogger is what your logrus-enabled library should take, that way |
|
| 94 |
+// it'll accept a stdlib logger and a logrus logger. There's no standard |
|
| 95 |
+// interface, this is the closest we get, unfortunately. |
|
| 96 |
+type StdLogger interface {
|
|
| 97 |
+ Print(...interface{})
|
|
| 98 |
+ Printf(string, ...interface{})
|
|
| 99 |
+ Println(...interface{})
|
|
| 100 |
+ |
|
| 101 |
+ Fatal(...interface{})
|
|
| 102 |
+ Fatalf(string, ...interface{})
|
|
| 103 |
+ Fatalln(...interface{})
|
|
| 104 |
+ |
|
| 105 |
+ Panic(...interface{})
|
|
| 106 |
+ Panicf(string, ...interface{})
|
|
| 107 |
+ Panicln(...interface{})
|
|
| 108 |
+} |
|
| 109 |
+ |
|
| 110 |
+// The FieldLogger interface generalizes the Entry and Logger types |
|
| 111 |
+type FieldLogger interface {
|
|
| 112 |
+ WithField(key string, value interface{}) *Entry
|
|
| 113 |
+ WithFields(fields Fields) *Entry |
|
| 114 |
+ WithError(err error) *Entry |
|
| 115 |
+ |
|
| 116 |
+ Debugf(format string, args ...interface{})
|
|
| 117 |
+ Infof(format string, args ...interface{})
|
|
| 118 |
+ Printf(format string, args ...interface{})
|
|
| 119 |
+ Warnf(format string, args ...interface{})
|
|
| 120 |
+ Warningf(format string, args ...interface{})
|
|
| 121 |
+ Errorf(format string, args ...interface{})
|
|
| 122 |
+ Fatalf(format string, args ...interface{})
|
|
| 123 |
+ Panicf(format string, args ...interface{})
|
|
| 124 |
+ |
|
| 125 |
+ Debug(args ...interface{})
|
|
| 126 |
+ Info(args ...interface{})
|
|
| 127 |
+ Print(args ...interface{})
|
|
| 128 |
+ Warn(args ...interface{})
|
|
| 129 |
+ Warning(args ...interface{})
|
|
| 130 |
+ Error(args ...interface{})
|
|
| 131 |
+ Fatal(args ...interface{})
|
|
| 132 |
+ Panic(args ...interface{})
|
|
| 133 |
+ |
|
| 134 |
+ Debugln(args ...interface{})
|
|
| 135 |
+ Infoln(args ...interface{})
|
|
| 136 |
+ Println(args ...interface{})
|
|
| 137 |
+ Warnln(args ...interface{})
|
|
| 138 |
+ Warningln(args ...interface{})
|
|
| 139 |
+ Errorln(args ...interface{})
|
|
| 140 |
+ Fatalln(args ...interface{})
|
|
| 141 |
+ Panicln(args ...interface{})
|
|
| 142 |
+} |
| 0 | 10 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,14 @@ |
| 0 |
+// Based on ssh/terminal: |
|
| 1 |
+// Copyright 2013 The Go Authors. All rights reserved. |
|
| 2 |
+// Use of this source code is governed by a BSD-style |
|
| 3 |
+// license that can be found in the LICENSE file. |
|
| 4 |
+ |
|
| 5 |
+// +build !appengine |
|
| 6 |
+ |
|
| 7 |
+package logrus |
|
| 8 |
+ |
|
| 9 |
+import "syscall" |
|
| 10 |
+ |
|
| 11 |
+const ioctlReadTermios = syscall.TCGETS |
|
| 12 |
+ |
|
| 13 |
+type Termios syscall.Termios |
| 0 | 14 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,28 @@ |
| 0 |
+// Based on ssh/terminal: |
|
| 1 |
+// Copyright 2011 The Go Authors. All rights reserved. |
|
| 2 |
+// Use of this source code is governed by a BSD-style |
|
| 3 |
+// license that can be found in the LICENSE file. |
|
| 4 |
+ |
|
| 5 |
+// +build linux darwin freebsd openbsd netbsd dragonfly |
|
| 6 |
+// +build !appengine |
|
| 7 |
+ |
|
| 8 |
+package logrus |
|
| 9 |
+ |
|
| 10 |
+import ( |
|
| 11 |
+ "io" |
|
| 12 |
+ "os" |
|
| 13 |
+ "syscall" |
|
| 14 |
+ "unsafe" |
|
| 15 |
+) |
|
| 16 |
+ |
|
| 17 |
+// IsTerminal returns true if stderr's file descriptor is a terminal. |
|
| 18 |
+func IsTerminal(f io.Writer) bool {
|
|
| 19 |
+ var termios Termios |
|
| 20 |
+ switch v := f.(type) {
|
|
| 21 |
+ case *os.File: |
|
| 22 |
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) |
|
| 23 |
+ return err == 0 |
|
| 24 |
+ default: |
|
| 25 |
+ return false |
|
| 26 |
+ } |
|
| 27 |
+} |
| 0 | 28 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+// +build solaris,!appengine |
|
| 1 |
+ |
|
| 2 |
+package logrus |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "io" |
|
| 6 |
+ "os" |
|
| 7 |
+ |
|
| 8 |
+ "golang.org/x/sys/unix" |
|
| 9 |
+) |
|
| 10 |
+ |
|
| 11 |
+// IsTerminal returns true if the given file descriptor is a terminal. |
|
| 12 |
+func IsTerminal(f io.Writer) bool {
|
|
| 13 |
+ switch v := f.(type) {
|
|
| 14 |
+ case *os.File: |
|
| 15 |
+ _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) |
|
| 16 |
+ return err == nil |
|
| 17 |
+ default: |
|
| 18 |
+ return false |
|
| 19 |
+ } |
|
| 20 |
+} |
| 0 | 21 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,82 @@ |
| 0 |
+// Based on ssh/terminal: |
|
| 1 |
+// Copyright 2011 The Go Authors. All rights reserved. |
|
| 2 |
+// Use of this source code is governed by a BSD-style |
|
| 3 |
+// license that can be found in the LICENSE file. |
|
| 4 |
+ |
|
| 5 |
+// +build windows,!appengine |
|
| 6 |
+ |
|
| 7 |
+package logrus |
|
| 8 |
+ |
|
| 9 |
+import ( |
|
| 10 |
+ "bytes" |
|
| 11 |
+ "errors" |
|
| 12 |
+ "io" |
|
| 13 |
+ "os" |
|
| 14 |
+ "os/exec" |
|
| 15 |
+ "strconv" |
|
| 16 |
+ "strings" |
|
| 17 |
+ "syscall" |
|
| 18 |
+ "unsafe" |
|
| 19 |
+) |
|
| 20 |
+ |
|
| 21 |
+var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
| 22 |
+ |
|
| 23 |
+var ( |
|
| 24 |
+ procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
|
| 25 |
+ procSetConsoleMode = kernel32.NewProc("SetConsoleMode")
|
|
| 26 |
+) |
|
| 27 |
+ |
|
| 28 |
+const ( |
|
| 29 |
+ enableProcessedOutput = 0x0001 |
|
| 30 |
+ enableWrapAtEolOutput = 0x0002 |
|
| 31 |
+ enableVirtualTerminalProcessing = 0x0004 |
|
| 32 |
+) |
|
| 33 |
+ |
|
| 34 |
+func getVersion() (float64, error) {
|
|
| 35 |
+ stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{}
|
|
| 36 |
+ cmd := exec.Command("cmd", "ver")
|
|
| 37 |
+ cmd.Stdout = stdout |
|
| 38 |
+ cmd.Stderr = stderr |
|
| 39 |
+ err := cmd.Run() |
|
| 40 |
+ if err != nil {
|
|
| 41 |
+ return -1, err |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ // The output should be like "Microsoft Windows [Version XX.X.XXXXXX]" |
|
| 45 |
+ version := strings.Replace(stdout.String(), "\n", "", -1) |
|
| 46 |
+ version = strings.Replace(version, "\r\n", "", -1) |
|
| 47 |
+ |
|
| 48 |
+ x1 := strings.Index(version, "[Version") |
|
| 49 |
+ |
|
| 50 |
+ if x1 == -1 || strings.Index(version, "]") == -1 {
|
|
| 51 |
+ return -1, errors.New("Can't determine Windows version")
|
|
| 52 |
+ } |
|
| 53 |
+ |
|
| 54 |
+ return strconv.ParseFloat(version[x1+9:x1+13], 64) |
|
| 55 |
+} |
|
| 56 |
+ |
|
| 57 |
+func init() {
|
|
| 58 |
+ ver, err := getVersion() |
|
| 59 |
+ if err != nil {
|
|
| 60 |
+ return |
|
| 61 |
+ } |
|
| 62 |
+ |
|
| 63 |
+ // Activate Virtual Processing for Windows CMD |
|
| 64 |
+ // Info: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx |
|
| 65 |
+ if ver >= 10 {
|
|
| 66 |
+ handle := syscall.Handle(os.Stderr.Fd()) |
|
| 67 |
+ procSetConsoleMode.Call(uintptr(handle), enableProcessedOutput|enableWrapAtEolOutput|enableVirtualTerminalProcessing) |
|
| 68 |
+ } |
|
| 69 |
+} |
|
| 70 |
+ |
|
| 71 |
+// IsTerminal returns true if stderr's file descriptor is a terminal. |
|
| 72 |
+func IsTerminal(f io.Writer) bool {
|
|
| 73 |
+ switch v := f.(type) {
|
|
| 74 |
+ case *os.File: |
|
| 75 |
+ var st uint32 |
|
| 76 |
+ r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) |
|
| 77 |
+ return r != 0 && e == 0 |
|
| 78 |
+ default: |
|
| 79 |
+ return false |
|
| 80 |
+ } |
|
| 81 |
+} |
| 0 | 82 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,196 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "bytes" |
|
| 4 |
+ "fmt" |
|
| 5 |
+ "sort" |
|
| 6 |
+ "strings" |
|
| 7 |
+ "sync" |
|
| 8 |
+ "time" |
|
| 9 |
+) |
|
| 10 |
+ |
|
| 11 |
+const ( |
|
| 12 |
+ nocolor = 0 |
|
| 13 |
+ red = 31 |
|
| 14 |
+ green = 32 |
|
| 15 |
+ yellow = 33 |
|
| 16 |
+ blue = 34 |
|
| 17 |
+ gray = 37 |
|
| 18 |
+) |
|
| 19 |
+ |
|
| 20 |
+var ( |
|
| 21 |
+ baseTimestamp time.Time |
|
| 22 |
+) |
|
| 23 |
+ |
|
| 24 |
+func init() {
|
|
| 25 |
+ baseTimestamp = time.Now() |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+type TextFormatter struct {
|
|
| 29 |
+ // Set to true to bypass checking for a TTY before outputting colors. |
|
| 30 |
+ ForceColors bool |
|
| 31 |
+ |
|
| 32 |
+ // Force disabling colors. |
|
| 33 |
+ DisableColors bool |
|
| 34 |
+ |
|
| 35 |
+ // Disable timestamp logging. useful when output is redirected to logging |
|
| 36 |
+ // system that already adds timestamps. |
|
| 37 |
+ DisableTimestamp bool |
|
| 38 |
+ |
|
| 39 |
+ // Enable logging the full timestamp when a TTY is attached instead of just |
|
| 40 |
+ // the time passed since beginning of execution. |
|
| 41 |
+ FullTimestamp bool |
|
| 42 |
+ |
|
| 43 |
+ // TimestampFormat to use for display when a full timestamp is printed |
|
| 44 |
+ TimestampFormat string |
|
| 45 |
+ |
|
| 46 |
+ // The fields are sorted by default for a consistent output. For applications |
|
| 47 |
+ // that log extremely frequently and don't use the JSON formatter this may not |
|
| 48 |
+ // be desired. |
|
| 49 |
+ DisableSorting bool |
|
| 50 |
+ |
|
| 51 |
+ // QuoteEmptyFields will wrap empty fields in quotes if true |
|
| 52 |
+ QuoteEmptyFields bool |
|
| 53 |
+ |
|
| 54 |
+ // QuoteCharacter can be set to the override the default quoting character " |
|
| 55 |
+ // with something else. For example: ', or `. |
|
| 56 |
+ QuoteCharacter string |
|
| 57 |
+ |
|
| 58 |
+ // Whether the logger's out is to a terminal |
|
| 59 |
+ isTerminal bool |
|
| 60 |
+ |
|
| 61 |
+ sync.Once |
|
| 62 |
+} |
|
| 63 |
+ |
|
| 64 |
+func (f *TextFormatter) init(entry *Entry) {
|
|
| 65 |
+ if len(f.QuoteCharacter) == 0 {
|
|
| 66 |
+ f.QuoteCharacter = "\"" |
|
| 67 |
+ } |
|
| 68 |
+ if entry.Logger != nil {
|
|
| 69 |
+ f.isTerminal = IsTerminal(entry.Logger.Out) |
|
| 70 |
+ } |
|
| 71 |
+} |
|
| 72 |
+ |
|
| 73 |
+func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
|
| 74 |
+ var b *bytes.Buffer |
|
| 75 |
+ keys := make([]string, 0, len(entry.Data)) |
|
| 76 |
+ for k := range entry.Data {
|
|
| 77 |
+ keys = append(keys, k) |
|
| 78 |
+ } |
|
| 79 |
+ |
|
| 80 |
+ if !f.DisableSorting {
|
|
| 81 |
+ sort.Strings(keys) |
|
| 82 |
+ } |
|
| 83 |
+ if entry.Buffer != nil {
|
|
| 84 |
+ b = entry.Buffer |
|
| 85 |
+ } else {
|
|
| 86 |
+ b = &bytes.Buffer{}
|
|
| 87 |
+ } |
|
| 88 |
+ |
|
| 89 |
+ prefixFieldClashes(entry.Data) |
|
| 90 |
+ |
|
| 91 |
+ f.Do(func() { f.init(entry) })
|
|
| 92 |
+ |
|
| 93 |
+ isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors |
|
| 94 |
+ |
|
| 95 |
+ timestampFormat := f.TimestampFormat |
|
| 96 |
+ if timestampFormat == "" {
|
|
| 97 |
+ timestampFormat = DefaultTimestampFormat |
|
| 98 |
+ } |
|
| 99 |
+ if isColored {
|
|
| 100 |
+ f.printColored(b, entry, keys, timestampFormat) |
|
| 101 |
+ } else {
|
|
| 102 |
+ if !f.DisableTimestamp {
|
|
| 103 |
+ f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) |
|
| 104 |
+ } |
|
| 105 |
+ f.appendKeyValue(b, "level", entry.Level.String()) |
|
| 106 |
+ if entry.Message != "" {
|
|
| 107 |
+ f.appendKeyValue(b, "msg", entry.Message) |
|
| 108 |
+ } |
|
| 109 |
+ for _, key := range keys {
|
|
| 110 |
+ f.appendKeyValue(b, key, entry.Data[key]) |
|
| 111 |
+ } |
|
| 112 |
+ } |
|
| 113 |
+ |
|
| 114 |
+ b.WriteByte('\n')
|
|
| 115 |
+ return b.Bytes(), nil |
|
| 116 |
+} |
|
| 117 |
+ |
|
| 118 |
+func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
|
|
| 119 |
+ var levelColor int |
|
| 120 |
+ switch entry.Level {
|
|
| 121 |
+ case DebugLevel: |
|
| 122 |
+ levelColor = gray |
|
| 123 |
+ case WarnLevel: |
|
| 124 |
+ levelColor = yellow |
|
| 125 |
+ case ErrorLevel, FatalLevel, PanicLevel: |
|
| 126 |
+ levelColor = red |
|
| 127 |
+ default: |
|
| 128 |
+ levelColor = blue |
|
| 129 |
+ } |
|
| 130 |
+ |
|
| 131 |
+ levelText := strings.ToUpper(entry.Level.String())[0:4] |
|
| 132 |
+ |
|
| 133 |
+ if f.DisableTimestamp {
|
|
| 134 |
+ fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message) |
|
| 135 |
+ } else if !f.FullTimestamp {
|
|
| 136 |
+ fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), entry.Message) |
|
| 137 |
+ } else {
|
|
| 138 |
+ fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) |
|
| 139 |
+ } |
|
| 140 |
+ for _, k := range keys {
|
|
| 141 |
+ v := entry.Data[k] |
|
| 142 |
+ fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k) |
|
| 143 |
+ f.appendValue(b, v) |
|
| 144 |
+ } |
|
| 145 |
+} |
|
| 146 |
+ |
|
| 147 |
+func (f *TextFormatter) needsQuoting(text string) bool {
|
|
| 148 |
+ if f.QuoteEmptyFields && len(text) == 0 {
|
|
| 149 |
+ return true |
|
| 150 |
+ } |
|
| 151 |
+ for _, ch := range text {
|
|
| 152 |
+ if !((ch >= 'a' && ch <= 'z') || |
|
| 153 |
+ (ch >= 'A' && ch <= 'Z') || |
|
| 154 |
+ (ch >= '0' && ch <= '9') || |
|
| 155 |
+ ch == '-' || ch == '.') {
|
|
| 156 |
+ return true |
|
| 157 |
+ } |
|
| 158 |
+ } |
|
| 159 |
+ return false |
|
| 160 |
+} |
|
| 161 |
+ |
|
| 162 |
+func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
|
|
| 163 |
+ |
|
| 164 |
+ b.WriteString(key) |
|
| 165 |
+ b.WriteByte('=')
|
|
| 166 |
+ f.appendValue(b, value) |
|
| 167 |
+ b.WriteByte(' ')
|
|
| 168 |
+} |
|
| 169 |
+ |
|
| 170 |
+func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
|
|
| 171 |
+ switch value := value.(type) {
|
|
| 172 |
+ case string: |
|
| 173 |
+ if !f.needsQuoting(value) {
|
|
| 174 |
+ b.WriteString(value) |
|
| 175 |
+ } else {
|
|
| 176 |
+ b.WriteString(f.quoteString(value)) |
|
| 177 |
+ } |
|
| 178 |
+ case error: |
|
| 179 |
+ errmsg := value.Error() |
|
| 180 |
+ if !f.needsQuoting(errmsg) {
|
|
| 181 |
+ b.WriteString(errmsg) |
|
| 182 |
+ } else {
|
|
| 183 |
+ b.WriteString(f.quoteString(errmsg)) |
|
| 184 |
+ } |
|
| 185 |
+ default: |
|
| 186 |
+ fmt.Fprint(b, value) |
|
| 187 |
+ } |
|
| 188 |
+} |
|
| 189 |
+ |
|
| 190 |
+func (f *TextFormatter) quoteString(v string) string {
|
|
| 191 |
+ escapedQuote := fmt.Sprintf("\\%s", f.QuoteCharacter)
|
|
| 192 |
+ escapedValue := strings.Replace(v, f.QuoteCharacter, escapedQuote, -1) |
|
| 193 |
+ |
|
| 194 |
+ return fmt.Sprintf("%s%v%s", f.QuoteCharacter, escapedValue, f.QuoteCharacter)
|
|
| 195 |
+} |
| 0 | 196 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,62 @@ |
| 0 |
+package logrus |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "bufio" |
|
| 4 |
+ "io" |
|
| 5 |
+ "runtime" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+func (logger *Logger) Writer() *io.PipeWriter {
|
|
| 9 |
+ return logger.WriterLevel(InfoLevel) |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
|
|
| 13 |
+ return NewEntry(logger).WriterLevel(level) |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+func (entry *Entry) Writer() *io.PipeWriter {
|
|
| 17 |
+ return entry.WriterLevel(InfoLevel) |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+func (entry *Entry) WriterLevel(level Level) *io.PipeWriter {
|
|
| 21 |
+ reader, writer := io.Pipe() |
|
| 22 |
+ |
|
| 23 |
+ var printFunc func(args ...interface{})
|
|
| 24 |
+ |
|
| 25 |
+ switch level {
|
|
| 26 |
+ case DebugLevel: |
|
| 27 |
+ printFunc = entry.Debug |
|
| 28 |
+ case InfoLevel: |
|
| 29 |
+ printFunc = entry.Info |
|
| 30 |
+ case WarnLevel: |
|
| 31 |
+ printFunc = entry.Warn |
|
| 32 |
+ case ErrorLevel: |
|
| 33 |
+ printFunc = entry.Error |
|
| 34 |
+ case FatalLevel: |
|
| 35 |
+ printFunc = entry.Fatal |
|
| 36 |
+ case PanicLevel: |
|
| 37 |
+ printFunc = entry.Panic |
|
| 38 |
+ default: |
|
| 39 |
+ printFunc = entry.Print |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ go entry.writerScanner(reader, printFunc) |
|
| 43 |
+ runtime.SetFinalizer(writer, writerFinalizer) |
|
| 44 |
+ |
|
| 45 |
+ return writer |
|
| 46 |
+} |
|
| 47 |
+ |
|
| 48 |
+func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
|
|
| 49 |
+ scanner := bufio.NewScanner(reader) |
|
| 50 |
+ for scanner.Scan() {
|
|
| 51 |
+ printFunc(scanner.Text()) |
|
| 52 |
+ } |
|
| 53 |
+ if err := scanner.Err(); err != nil {
|
|
| 54 |
+ entry.Errorf("Error while reading from Writer: %s", err)
|
|
| 55 |
+ } |
|
| 56 |
+ reader.Close() |
|
| 57 |
+} |
|
| 58 |
+ |
|
| 59 |
+func writerFinalizer(writer *io.PipeWriter) {
|
|
| 60 |
+ writer.Close() |
|
| 61 |
+} |
| ... | ... |
@@ -15,11 +15,11 @@ import ( |
| 15 | 15 |
|
| 16 | 16 |
"github.com/pkg/errors" |
| 17 | 17 |
|
| 18 |
- "github.com/Sirupsen/logrus" |
|
| 19 | 18 |
"github.com/docker/docker/api" |
| 20 | 19 |
"github.com/docker/docker/pkg/idtools" |
| 21 | 20 |
"github.com/docker/docker/pkg/mount" |
| 22 | 21 |
"github.com/docker/docker/volume" |
| 22 |
+ "github.com/sirupsen/logrus" |
|
| 23 | 23 |
) |
| 24 | 24 |
|
| 25 | 25 |
// VolumeDataPathName is the name of the directory where the volume data is stored. |
| ... | ... |
@@ -3,10 +3,10 @@ package store |
| 3 | 3 |
import ( |
| 4 | 4 |
"sync" |
| 5 | 5 |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 | 6 |
"github.com/boltdb/bolt" |
| 8 | 7 |
"github.com/docker/docker/volume" |
| 9 | 8 |
"github.com/docker/docker/volume/drivers" |
| 9 |
+ "github.com/sirupsen/logrus" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// restore is called when a new volume store is created. |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/pkg/errors" |
| 11 | 11 |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 | 12 |
"github.com/boltdb/bolt" |
| 14 | 13 |
"github.com/docker/docker/pkg/locker" |
| 15 | 14 |
"github.com/docker/docker/volume" |
| 16 | 15 |
"github.com/docker/docker/volume/drivers" |
| 16 |
+ "github.com/sirupsen/logrus" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
const ( |