diff --git a/blockservice/blockservice.go b/blockservice/blockservice.go index 6970f363b..21bb75c6f 100644 --- a/blockservice/blockservice.go +++ b/blockservice/blockservice.go @@ -7,14 +7,13 @@ import ( context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" blocks "github.com/jbenet/go-ipfs/blocks" exchange "github.com/jbenet/go-ipfs/exchange" u "github.com/jbenet/go-ipfs/util" ) -var log = u.Logger("blockservice", logging.ERROR) +var log = u.Logger("blockservice") // 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 9be051850..7b75ba5c5 100644 --- a/cmd/ipfs/ipfs.go +++ b/cmd/ipfs/ipfs.go @@ -9,7 +9,6 @@ import ( flag "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" commander "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" config "github.com/jbenet/go-ipfs/config" core "github.com/jbenet/go-ipfs/core" @@ -62,7 +61,7 @@ Use "ipfs help " for more information about a command. } // log is the command logger -var log = u.Logger("cmd/ipfs", logging.ERROR) +var log = u.Logger("cmd/ipfs") func init() { config, err := config.PathRoot() diff --git a/core/commands/commands.go b/core/commands/commands.go index f6e681b4c..0c2541146 100644 --- a/core/commands/commands.go +++ b/core/commands/commands.go @@ -5,10 +5,8 @@ import ( "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 = u.Logger("commands", logging.ERROR) +var log = u.Logger("commands") type CmdFunc func(*core.IpfsNode, []string, map[string]interface{}, io.Writer) error diff --git a/core/core.go b/core/core.go index 966a8e710..427c33c29 100644 --- a/core/core.go +++ b/core/core.go @@ -9,7 +9,6 @@ import ( ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go" b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" bserv "github.com/jbenet/go-ipfs/blockservice" config "github.com/jbenet/go-ipfs/config" @@ -28,7 +27,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = u.Logger("core", logging.ERROR) +var log = u.Logger("core") // IpfsNode is IPFS Core module. It represents an IPFS instance. type IpfsNode struct { diff --git a/daemon/daemon.go b/daemon/daemon.go index c40b99cb2..02fe49023 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -9,7 +9,6 @@ import ( "path" "sync" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" core "github.com/jbenet/go-ipfs/core" "github.com/jbenet/go-ipfs/core/commands" u "github.com/jbenet/go-ipfs/util" @@ -18,7 +17,7 @@ import ( ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ) -var log = u.Logger("daemon", logging.ERROR) +var log = u.Logger("daemon") // 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 bfea7c4f7..8687fc725 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -11,7 +11,6 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" "github.com/jbenet/go-ipfs/core" ci "github.com/jbenet/go-ipfs/crypto" @@ -20,7 +19,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = u.Logger("ipns", logging.ERROR) +var log = u.Logger("ipns") // 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 ac4b8d7a4..1bd45e8c2 100644 --- a/fuse/readonly/readonly_unix.go +++ b/fuse/readonly/readonly_unix.go @@ -21,10 +21,9 @@ import ( core "github.com/jbenet/go-ipfs/core" mdag "github.com/jbenet/go-ipfs/merkledag" u "github.com/jbenet/go-ipfs/util" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = u.Logger("ipfs", logging.ERROR) +var log = u.Logger("ipfs") // FileSystem is the readonly Ipfs Fuse Filesystem. type FileSystem struct { diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index c5db9e00f..076128155 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -4,7 +4,6 @@ import ( "fmt" proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" blocks "github.com/jbenet/go-ipfs/blocks" @@ -12,7 +11,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var log = u.Logger("merkledag", logging.ERROR) +var log = u.Logger("merkledag") // NodeMap maps u.Keys to Nodes. // We cannot use []byte/Multihash for keys :( diff --git a/namesys/routing.go b/namesys/routing.go index ba7c4a723..942263e8e 100644 --- a/namesys/routing.go +++ b/namesys/routing.go @@ -6,15 +6,14 @@ import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" + mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" ci "github.com/jbenet/go-ipfs/crypto" mdag "github.com/jbenet/go-ipfs/merkledag" "github.com/jbenet/go-ipfs/routing" u "github.com/jbenet/go-ipfs/util" - mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = u.Logger("namesys", logging.ERROR) +var log = u.Logger("namesys") // RoutingResolver implements NSResolver for the main IPFS SFS-like naming type RoutingResolver struct { diff --git a/path/path.go b/path/path.go index 83d1aa8b6..239203140 100644 --- a/path/path.go +++ b/path/path.go @@ -8,10 +8,9 @@ import ( mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" merkledag "github.com/jbenet/go-ipfs/merkledag" u "github.com/jbenet/go-ipfs/util" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" ) -var log = u.Logger("path", logging.ERROR) +var log = u.Logger("path") // 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 d45c5aabf..8cf3a1153 100644 --- a/routing/dht/dht.go +++ b/routing/dht/dht.go @@ -17,12 +17,11 @@ import ( context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto" ) -var log = u.Logger("dht", logging.ERROR) +var log = u.Logger("dht") // 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 8a44cb982..1e51064ed 100644 --- a/util/util.go +++ b/util/util.go @@ -107,6 +107,8 @@ func DOut(format string, a ...interface{}) { } } +var loggers = []string{} + // SetupLogging will initialize the logger backend and set the flags. func SetupLogging() { backend := logging.NewLogBackend(os.Stderr, "", 0) @@ -119,12 +121,17 @@ func SetupLogging() { } */ logging.SetFormatter(logging.MustStringFormatter(LogFormat)) + + for _, n := range loggers { + logging.SetLevel(logging.ERROR, n) + } } // Logger retrieves a particular logger + initializes it at a particular level -func Logger(name string, lvl logging.Level) *logging.Logger { +func Logger(name string) *logging.Logger { log := logging.MustGetLogger(name) - logging.SetLevel(lvl, name) + // logging.SetLevel(lvl, name) // can't set level here. + loggers = append(loggers, name) return log }