From 31173ff4b4e0aa43ab987a66aea65bf8be2973dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 8 Jan 2020 14:49:34 +0100 Subject: [PATCH] Set logging levels in a single place --- cmd/lotus-seal-worker/main.go | 3 ++- cmd/lotus-storage-miner/main.go | 4 ++-- cmd/lotus/main.go | 9 ++------- lib/lotuslog/levels.go | 12 ++++++++++++ 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 lib/lotuslog/levels.go diff --git a/cmd/lotus-seal-worker/main.go b/cmd/lotus-seal-worker/main.go index 57d2bf655..146c246e8 100644 --- a/cmd/lotus-seal-worker/main.go +++ b/cmd/lotus-seal-worker/main.go @@ -12,6 +12,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/lib/lotuslog" "github.com/filecoin-project/lotus/node/repo" manet "github.com/multiformats/go-multiaddr-net" ) @@ -19,7 +20,7 @@ import ( var log = logging.Logger("main") func main() { - logging.SetLogLevel("*", "INFO") + lotuslog.SetupLogLevels() log.Info("Starting lotus worker") diff --git a/cmd/lotus-storage-miner/main.go b/cmd/lotus-storage-miner/main.go index 00c170703..c05383116 100644 --- a/cmd/lotus-storage-miner/main.go +++ b/cmd/lotus-storage-miner/main.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/lotus/build" lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/lib/lotuslog" "github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/tracing" ) @@ -18,8 +19,7 @@ var log = logging.Logger("main") const FlagStorageRepo = "storagerepo" func main() { - logging.SetLogLevel("*", "INFO") - logging.SetLogLevel("swarm", "WARN") + lotuslog.SetupLogLevels() local := []*cli.Command{ runCmd, diff --git a/cmd/lotus/main.go b/cmd/lotus/main.go index 2892d9358..3f081222d 100644 --- a/cmd/lotus/main.go +++ b/cmd/lotus/main.go @@ -4,23 +4,18 @@ import ( "context" "os" - logging "github.com/ipfs/go-log" "go.opencensus.io/trace" "gopkg.in/urfave/cli.v2" "github.com/filecoin-project/lotus/build" lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/lib/lotuslog" "github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/tracing" ) func main() { - logging.SetLogLevel("*", "INFO") - logging.SetLogLevel("dht", "ERROR") - logging.SetLogLevel("swarm2", "WARN") - logging.SetLogLevel("bitswap", "WARN") - logging.SetLogLevel("pubsub", "WARN") - logging.SetLogLevel("connmgr", "WARN") + lotuslog.SetupLogLevels() local := []*cli.Command{ DaemonCmd, diff --git a/lib/lotuslog/levels.go b/lib/lotuslog/levels.go new file mode 100644 index 000000000..ddb70535c --- /dev/null +++ b/lib/lotuslog/levels.go @@ -0,0 +1,12 @@ +package lotuslog + +import logging "github.com/ipfs/go-log" + +func SetupLogLevels() { + logging.SetLogLevel("*", "INFO") + logging.SetLogLevel("dht", "ERROR") + logging.SetLogLevel("swarm2", "WARN") + logging.SetLogLevel("bitswap", "WARN") + logging.SetLogLevel("pubsub", "WARN") + logging.SetLogLevel("connmgr", "WARN") +}