mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-16 15:17:53 +08:00
loggers: set level
This commit is contained in:
@ -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.
|
||||
|
@ -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 <command>" 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()
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 :(
|
||||
|
@ -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 {
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
||||
|
11
util/util.go
11
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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user