mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-17 16:37:59 +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"
|
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"
|
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"
|
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"
|
blocks "github.com/jbenet/go-ipfs/blocks"
|
||||||
exchange "github.com/jbenet/go-ipfs/exchange"
|
exchange "github.com/jbenet/go-ipfs/exchange"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = u.Logger("blockservice", logging.ERROR)
|
var log = u.Logger("blockservice")
|
||||||
|
|
||||||
// BlockService is a block datastore.
|
// BlockService is a block datastore.
|
||||||
// It uses an internal `datastore.Datastore` instance to store values.
|
// 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"
|
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"
|
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"
|
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"
|
config "github.com/jbenet/go-ipfs/config"
|
||||||
core "github.com/jbenet/go-ipfs/core"
|
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
|
// log is the command logger
|
||||||
var log = u.Logger("cmd/ipfs", logging.ERROR)
|
var log = u.Logger("cmd/ipfs")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
config, err := config.PathRoot()
|
config, err := config.PathRoot()
|
||||||
|
@ -5,10 +5,8 @@ import (
|
|||||||
|
|
||||||
"github.com/jbenet/go-ipfs/core"
|
"github.com/jbenet/go-ipfs/core"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
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
|
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"
|
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"
|
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"
|
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"
|
bserv "github.com/jbenet/go-ipfs/blockservice"
|
||||||
config "github.com/jbenet/go-ipfs/config"
|
config "github.com/jbenet/go-ipfs/config"
|
||||||
@ -28,7 +27,7 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
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.
|
// IpfsNode is IPFS Core module. It represents an IPFS instance.
|
||||||
type IpfsNode struct {
|
type IpfsNode struct {
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
logging "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
|
|
||||||
core "github.com/jbenet/go-ipfs/core"
|
core "github.com/jbenet/go-ipfs/core"
|
||||||
"github.com/jbenet/go-ipfs/core/commands"
|
"github.com/jbenet/go-ipfs/core/commands"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
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"
|
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
|
// LockFile is the filename of the daemon lock, relative to config dir
|
||||||
const LockFile = "daemon.lock"
|
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"
|
||||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
|
"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"
|
"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"
|
"github.com/jbenet/go-ipfs/core"
|
||||||
ci "github.com/jbenet/go-ipfs/crypto"
|
ci "github.com/jbenet/go-ipfs/crypto"
|
||||||
@ -20,7 +19,7 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
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.
|
// FileSystem is the readwrite IPNS Fuse Filesystem.
|
||||||
type FileSystem struct {
|
type FileSystem struct {
|
||||||
|
@ -21,10 +21,9 @@ import (
|
|||||||
core "github.com/jbenet/go-ipfs/core"
|
core "github.com/jbenet/go-ipfs/core"
|
||||||
mdag "github.com/jbenet/go-ipfs/merkledag"
|
mdag "github.com/jbenet/go-ipfs/merkledag"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
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.
|
// FileSystem is the readonly Ipfs Fuse Filesystem.
|
||||||
type FileSystem struct {
|
type FileSystem struct {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
|
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"
|
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
||||||
blocks "github.com/jbenet/go-ipfs/blocks"
|
blocks "github.com/jbenet/go-ipfs/blocks"
|
||||||
@ -12,7 +11,7 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
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.
|
// NodeMap maps u.Keys to Nodes.
|
||||||
// We cannot use []byte/Multihash for keys :(
|
// 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/go.net/context"
|
||||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
|
"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"
|
ci "github.com/jbenet/go-ipfs/crypto"
|
||||||
mdag "github.com/jbenet/go-ipfs/merkledag"
|
mdag "github.com/jbenet/go-ipfs/merkledag"
|
||||||
"github.com/jbenet/go-ipfs/routing"
|
"github.com/jbenet/go-ipfs/routing"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
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
|
// RoutingResolver implements NSResolver for the main IPFS SFS-like naming
|
||||||
type RoutingResolver struct {
|
type RoutingResolver struct {
|
||||||
|
@ -8,10 +8,9 @@ import (
|
|||||||
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
||||||
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
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
|
// Resolver provides path resolution to IPFS
|
||||||
// It has a pointer to a DAGService, which is uses to resolve nodes.
|
// 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"
|
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"
|
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"
|
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"
|
"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
|
// 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.
|
// SetupLogging will initialize the logger backend and set the flags.
|
||||||
func SetupLogging() {
|
func SetupLogging() {
|
||||||
backend := logging.NewLogBackend(os.Stderr, "", 0)
|
backend := logging.NewLogBackend(os.Stderr, "", 0)
|
||||||
@ -119,12 +121,17 @@ func SetupLogging() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
logging.SetFormatter(logging.MustStringFormatter(LogFormat))
|
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
|
// 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)
|
log := logging.MustGetLogger(name)
|
||||||
logging.SetLevel(lvl, name)
|
// logging.SetLevel(lvl, name) // can't set level here.
|
||||||
|
loggers = append(loggers, name)
|
||||||
return log
|
return log
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user