loggers: set level
Juan Batiz-Benet committed
Oct 4, 2014 at 03:53 UTC
0c8ae7674e96dc47f4932b23a13a69d16b0deada
12 files changed
+21
-26
blockservice/blockservice.go
+1
-2
@@ -7,14 +7,13 @@ import (
7
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
8
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
9
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
10
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
10
11
blocks "github.com/jbenet/go-ipfs/blocks"
12
exchange "github.com/jbenet/go-ipfs/exchange"
13
u "github.com/jbenet/go-ipfs/util"
14
)
15
17
-var log = u.Logger("blockservice", logging.ERROR)
16
+var log = u.Logger("blockservice")
17
18
// BlockService is a block datastore.
19
// It uses an internal `datastore.Datastore` instance to store values.
cmd/ipfs/ipfs.go
+1
-2
@@ -9,7 +9,6 @@ import (
9
flag "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
10
commander "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
11
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
12
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
12
13
config "github.com/jbenet/go-ipfs/config"
14
core "github.com/jbenet/go-ipfs/core"
@@ -62,7 +61,7 @@ Use "ipfs help <command>" for more information about a command.
61
}
62
63
// log is the command logger
65
-var log = u.Logger("cmd/ipfs", logging.ERROR)
64
+var log = u.Logger("cmd/ipfs")
65
66
func init() {
67
config, err := config.PathRoot()
core/commands/commands.go
+1
-3
@@ -5,10 +5,8 @@ import (
5
6
"github.com/jbenet/go-ipfs/core"
7
u "github.com/jbenet/go-ipfs/util"
8
-
9
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
8
)
9
12
-var log = u.Logger("commands", logging.ERROR)
10
+var log = u.Logger("commands")
11
12
type CmdFunc func(*core.IpfsNode, []string, map[string]interface{}, io.Writer) error
core/core.go
+1
-2
@@ -9,7 +9,6 @@ import (
9
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
10
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
11
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
12
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
12
13
bserv "github.com/jbenet/go-ipfs/blockservice"
14
config "github.com/jbenet/go-ipfs/config"
@@ -28,7 +27,7 @@ import (
27
u "github.com/jbenet/go-ipfs/util"
28
)
29
31
-var log = u.Logger("core", logging.ERROR)
30
+var log = u.Logger("core")
31
32
// IpfsNode is IPFS Core module. It represents an IPFS instance.
33
type IpfsNode struct {
daemon/daemon.go
+1
-2
@@ -9,7 +9,6 @@ import (
9
"path"
10
"sync"
11
12
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
12
core "github.com/jbenet/go-ipfs/core"
13
"github.com/jbenet/go-ipfs/core/commands"
14
u "github.com/jbenet/go-ipfs/util"
@@ -18,7 +17,7 @@ import (
17
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
18
)
19
21
-var log = u.Logger("daemon", logging.ERROR)
20
+var log = u.Logger("daemon")
21
22
// LockFile is the filename of the daemon lock, relative to config dir
23
const LockFile = "daemon.lock"
fuse/ipns/ipns_unix.go
+1
-2
@@ -11,7 +11,6 @@ import (
11
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
12
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
13
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
14
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
14
15
"github.com/jbenet/go-ipfs/core"
16
ci "github.com/jbenet/go-ipfs/crypto"
@@ -20,7 +19,7 @@ import (
19
u "github.com/jbenet/go-ipfs/util"
20
)
21
23
-var log = u.Logger("ipns", logging.ERROR)
22
+var log = u.Logger("ipns")
23
24
// FileSystem is the readwrite IPNS Fuse Filesystem.
25
type FileSystem struct {
fuse/readonly/readonly_unix.go
+1
-2
@@ -21,10 +21,9 @@ import (
21
core "github.com/jbenet/go-ipfs/core"
22
mdag "github.com/jbenet/go-ipfs/merkledag"
23
u "github.com/jbenet/go-ipfs/util"
24
- "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
24
)
25
27
-var log = u.Logger("ipfs", logging.ERROR)
26
+var log = u.Logger("ipfs")
27
28
// FileSystem is the readonly Ipfs Fuse Filesystem.
29
type FileSystem struct {
merkledag/merkledag.go
+1
-2
@@ -4,7 +4,6 @@ import (
4
"fmt"
5
6
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
7
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
7
8
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
9
blocks "github.com/jbenet/go-ipfs/blocks"
@@ -12,7 +11,7 @@ import (
11
u "github.com/jbenet/go-ipfs/util"
12
)
13
15
-var log = u.Logger("merkledag", logging.ERROR)
14
+var log = u.Logger("merkledag")
15
16
// NodeMap maps u.Keys to Nodes.
17
// We cannot use []byte/Multihash for keys :(
namesys/routing.go
+2
-3
@@ -6,15 +6,14 @@ import (
6
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
8
9
+ mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
10
ci "github.com/jbenet/go-ipfs/crypto"
11
mdag "github.com/jbenet/go-ipfs/merkledag"
12
"github.com/jbenet/go-ipfs/routing"
13
u "github.com/jbenet/go-ipfs/util"
13
- mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
14
- "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
14
)
15
17
-var log = u.Logger("namesys", logging.ERROR)
16
+var log = u.Logger("namesys")
17
18
// RoutingResolver implements NSResolver for the main IPFS SFS-like naming
19
type RoutingResolver struct {
path/path.go
+1
-2
@@ -8,10 +8,9 @@ import (
8
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
9
merkledag "github.com/jbenet/go-ipfs/merkledag"
10
u "github.com/jbenet/go-ipfs/util"
11
- "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
11
)
12
14
-var log = u.Logger("path", logging.ERROR)
13
+var log = u.Logger("path")
14
15
// Resolver provides path resolution to IPFS
16
// It has a pointer to a DAGService, which is uses to resolve nodes.
routing/dht/dht.go
+1
-2
@@ -17,12 +17,11 @@ import (
17
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
18
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
19
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
20
- logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
20
21
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
22
)
23
25
-var log = u.Logger("dht", logging.ERROR)
24
+var log = u.Logger("dht")
25
26
// TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js
27
util/util.go
+9
-2
@@ -107,6 +107,8 @@ func DOut(format string, a ...interface{}) {
107
}
108
}
109
110
+var loggers = []string{}
111
+
112
// SetupLogging will initialize the logger backend and set the flags.
113
func SetupLogging() {
114
backend := logging.NewLogBackend(os.Stderr, "", 0)
@@ -119,12 +121,17 @@ func SetupLogging() {
121
}
122
*/
123
logging.SetFormatter(logging.MustStringFormatter(LogFormat))
124
+
125
+ for _, n := range loggers {
126
+ logging.SetLevel(logging.ERROR, n)
127
+ }
128
}
129
130
// Logger retrieves a particular logger + initializes it at a particular level
125
-func Logger(name string, lvl logging.Level) *logging.Logger {
131
+func Logger(name string) *logging.Logger {
132
log := logging.MustGetLogger(name)
127
- logging.SetLevel(lvl, name)
133
+ // logging.SetLevel(lvl, name) // can't set level here.
134
+ loggers = append(loggers, name)
135
return log
136
}
137