@cryptotaxi247 / kubo / commits / 7e1cd5925

initialize loggers at ERROR

Juan Batiz-Benet committed Oct 4, 2014 at 03:36 UTC 7e1cd592597acea22c198346cdfeebf6233c35ef
12 files changed +19 -13
blockservice/blockservice.go
+1 -1
@@ -14,7 +14,7 @@ import (
14 u "github.com/jbenet/go-ipfs/util"
15 )
16
17 -var log = logging.MustGetLogger("blockservice")
17 +var log = u.Logger("blockservice", logging.ERROR)
18
19 // BlockService is a block datastore.
20 // It uses an internal `datastore.Datastore` instance to store values.
cmd/ipfs/ipfs.go
+1 -1
@@ -62,7 +62,7 @@ Use "ipfs help <command>" for more information about a command.
62 }
63
64 // log is the command logger
65 -var log = logging.MustGetLogger("cmd/ipfs")
65 +var log = u.Logger("cmd/ipfs", logging.ERROR)
66
67 func init() {
68 config, err := config.PathRoot()
core/commands/commands.go
+2 -1
@@ -4,10 +4,11 @@ import (
4 "io"
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"
10 )
11
11 -var log = logging.MustGetLogger("commands")
12 +var log = u.Logger("commands", logging.ERROR)
13
14 type CmdFunc func(*core.IpfsNode, []string, map[string]interface{}, io.Writer) error
core/core.go
+1 -1
@@ -28,7 +28,7 @@ import (
28 u "github.com/jbenet/go-ipfs/util"
29 )
30
31 -var log = logging.MustGetLogger("core")
31 +var log = u.Logger("core", logging.ERROR)
32
33 // IpfsNode is IPFS Core module. It represents an IPFS instance.
34 type IpfsNode struct {
daemon/daemon.go
+1 -1
@@ -18,7 +18,7 @@ import (
18 ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
19 )
20
21 -var log = logging.MustGetLogger("daemon")
21 +var log = u.Logger("daemon", logging.ERROR)
22
23 // LockFile is the filename of the daemon lock, relative to config dir
24 const LockFile = "daemon.lock"
fuse/ipns/ipns_unix.go
+1 -1
@@ -20,7 +20,7 @@ import (
20 u "github.com/jbenet/go-ipfs/util"
21 )
22
23 -var log = logging.MustGetLogger("ipns")
23 +var log = u.Logger("ipns", logging.ERROR)
24
25 // FileSystem is the readwrite IPNS Fuse Filesystem.
26 type FileSystem struct {
fuse/readonly/readonly_unix.go
+1 -1
@@ -24,7 +24,7 @@ import (
24 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
25 )
26
27 -var log = logging.MustGetLogger("ipfs")
27 +var log = u.Logger("ipfs", logging.ERROR)
28
29 // FileSystem is the readonly Ipfs Fuse Filesystem.
30 type FileSystem struct {
merkledag/merkledag.go
+1 -1
@@ -12,7 +12,7 @@ import (
12 u "github.com/jbenet/go-ipfs/util"
13 )
14
15 -var log = logging.MustGetLogger("merkledag")
15 +var log = u.Logger("merkledag", logging.ERROR)
16
17 // NodeMap maps u.Keys to Nodes.
18 // We cannot use []byte/Multihash for keys :(
namesys/routing.go
+1 -1
@@ -14,7 +14,7 @@ import (
14 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
15 )
16
17 -var log = logging.MustGetLogger("namesys")
17 +var log = u.Logger("namesys", logging.ERROR)
18
19 // RoutingResolver implements NSResolver for the main IPFS SFS-like naming
20 type RoutingResolver struct {
path/path.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
12 )
13
14 -var log = logging.MustGetLogger("path")
14 +var log = u.Logger("path", logging.ERROR)
15
16 // Resolver provides path resolution to IPFS
17 // It has a pointer to a DAGService, which is uses to resolve nodes.
routing/dht/dht.go
+1 -1
@@ -22,7 +22,7 @@ import (
22 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
23 )
24
25 -var log = logging.MustGetLogger("dht")
25 +var log = u.Logger("dht", logging.ERROR)
26
27 // TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js
28
util/util.go
+7 -2
@@ -118,11 +118,16 @@ func SetupLogging() {
118 logging.SetLevel(logging.ERROR, "")
119 }
120 */
121 - logging.SetLevel(logging.ERROR, "merkledag")
122 - logging.SetLevel(logging.ERROR, "blockservice")
121 logging.SetFormatter(logging.MustStringFormatter(LogFormat))
122 }
123
124 +// Logger retrieves a particular logger + initializes it at a particular level
125 +func Logger(name string, lvl logging.Level) *logging.Logger {
126 + log := logging.MustGetLogger(name)
127 + logging.SetLevel(lvl, name)
128 + return log
129 +}
130 +
131 // ExpandPathnames takes a set of paths and turns them into absolute paths
132 func ExpandPathnames(paths []string) ([]string, error) {
133 var out []string