From 7e1cd592597acea22c198346cdfeebf6233c35ef Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 4 Oct 2014 03:36:30 -0700 Subject: [PATCH] initialize loggers at ERROR --- blockservice/blockservice.go | 2 +- cmd/ipfs/ipfs.go | 2 +- core/commands/commands.go | 3 ++- core/core.go | 2 +- daemon/daemon.go | 2 +- fuse/ipns/ipns_unix.go | 2 +- fuse/readonly/readonly_unix.go | 2 +- merkledag/merkledag.go | 2 +- namesys/routing.go | 2 +- path/path.go | 2 +- routing/dht/dht.go | 2 +- util/util.go | 9 +++++++-- 12 files changed, 19 insertions(+), 13 deletions(-) diff --git a/blockservice/blockservice.go b/blockservice/blockservice.go index 369cacc2a..6970f363b 100644 --- a/blockservice/blockservice.go +++ b/blockservice/blockservice.go @@ -14,7 +14,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = logging.MustGetLogger("blockservice") +var log = u.Logger("blockservice", logging.ERROR) // BlockService is a block datastore. // It uses an internal `datastore.Datastore` instance to store values. diff --git a/cmd/ipfs/ipfs.go b/cmd/ipfs/ipfs.go index 3d50e1b8d..9be051850 100644 --- a/cmd/ipfs/ipfs.go +++ b/cmd/ipfs/ipfs.go @@ -62,7 +62,7 @@ Use "ipfs help " for more information about a command. } // log is the command logger -var log = logging.MustGetLogger("cmd/ipfs") +var log = u.Logger("cmd/ipfs", logging.ERROR) func init() { config, err := config.PathRoot() diff --git a/core/commands/commands.go b/core/commands/commands.go index b356d9bbb..f6e681b4c 100644 --- a/core/commands/commands.go +++ b/core/commands/commands.go @@ -4,10 +4,11 @@ import ( "io" "github.com/jbenet/go-ipfs/core" + u "github.com/jbenet/go-ipfs/util" logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = logging.MustGetLogger("commands") +var log = u.Logger("commands", logging.ERROR) type CmdFunc func(*core.IpfsNode, []string, map[string]interface{}, io.Writer) error diff --git a/core/core.go b/core/core.go index 8fa209bba..966a8e710 100644 --- a/core/core.go +++ b/core/core.go @@ -28,7 +28,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = logging.MustGetLogger("core") +var log = u.Logger("core", logging.ERROR) // IpfsNode is IPFS Core module. It represents an IPFS instance. type IpfsNode struct { diff --git a/daemon/daemon.go b/daemon/daemon.go index 3ea4cc5da..c40b99cb2 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -18,7 +18,7 @@ import ( ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ) -var log = logging.MustGetLogger("daemon") +var log = u.Logger("daemon", logging.ERROR) // LockFile is the filename of the daemon lock, relative to config dir const LockFile = "daemon.lock" diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index 5312d9fff..bfea7c4f7 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -20,7 +20,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = logging.MustGetLogger("ipns") +var log = u.Logger("ipns", logging.ERROR) // FileSystem is the readwrite IPNS Fuse Filesystem. type FileSystem struct { diff --git a/fuse/readonly/readonly_unix.go b/fuse/readonly/readonly_unix.go index 8641916e2..ac4b8d7a4 100644 --- a/fuse/readonly/readonly_unix.go +++ b/fuse/readonly/readonly_unix.go @@ -24,7 +24,7 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = logging.MustGetLogger("ipfs") +var log = u.Logger("ipfs", logging.ERROR) // FileSystem is the readonly Ipfs Fuse Filesystem. type FileSystem struct { diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index e51a6e3c4..c5db9e00f 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -12,7 +12,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = logging.MustGetLogger("merkledag") +var log = u.Logger("merkledag", logging.ERROR) // NodeMap maps u.Keys to Nodes. // We cannot use []byte/Multihash for keys :( diff --git a/namesys/routing.go b/namesys/routing.go index 4c2b0d816..ba7c4a723 100644 --- a/namesys/routing.go +++ b/namesys/routing.go @@ -14,7 +14,7 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = logging.MustGetLogger("namesys") +var log = u.Logger("namesys", logging.ERROR) // RoutingResolver implements NSResolver for the main IPFS SFS-like naming type RoutingResolver struct { diff --git a/path/path.go b/path/path.go index ebc9d81d6..83d1aa8b6 100644 --- a/path/path.go +++ b/path/path.go @@ -11,7 +11,7 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = logging.MustGetLogger("path") +var log = u.Logger("path", logging.ERROR) // Resolver provides path resolution to IPFS // It has a pointer to a DAGService, which is uses to resolve nodes. diff --git a/routing/dht/dht.go b/routing/dht/dht.go index aa7361e53..d45c5aabf 100644 --- a/routing/dht/dht.go +++ b/routing/dht/dht.go @@ -22,7 +22,7 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" ) -var log = logging.MustGetLogger("dht") +var log = u.Logger("dht", logging.ERROR) // TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js diff --git a/util/util.go b/util/util.go index 8831c6831..8a44cb982 100644 --- a/util/util.go +++ b/util/util.go @@ -118,11 +118,16 @@ func SetupLogging() { logging.SetLevel(logging.ERROR, "") } */ - logging.SetLevel(logging.ERROR, "merkledag") - logging.SetLevel(logging.ERROR, "blockservice") logging.SetFormatter(logging.MustStringFormatter(LogFormat)) } +// Logger retrieves a particular logger + initializes it at a particular level +func Logger(name string, lvl logging.Level) *logging.Logger { + log := logging.MustGetLogger(name) + logging.SetLevel(lvl, name) + return log +} + // ExpandPathnames takes a set of paths and turns them into absolute paths func ExpandPathnames(paths []string) ([]string, error) { var out []string