diff --git a/cmd/main.go b/cmd/main.go index 00eb2b465db4..7538376e33b6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -270,6 +270,8 @@ func setLoggerLevel(c *cli.Context) { utils.SetLogLevel(logrus.DebugLevel) } else if c.Bool("quiet") { utils.SetLogLevel(logrus.WarnLevel) + } else { + utils.SetLogLevel(logrus.InfoLevel) } setupAgent(c) } diff --git a/go.mod b/go.mod index 0a1a92e72c4e..527bdf239a18 100644 --- a/go.mod +++ b/go.mod @@ -41,6 +41,7 @@ require ( github.com/minio/minio-go v6.0.14+incompatible github.com/ncw/swift v1.0.53 github.com/pengsrc/go-shared v0.2.0 // indirect + github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4 github.com/pkg/errors v0.9.1 github.com/pkg/sftp v1.10.0 github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect diff --git a/pkg/meta/benchmarks_test.go b/pkg/meta/benchmarks_test.go index e33d1f9c7f06..2aa7c2dc9320 100644 --- a/pkg/meta/benchmarks_test.go +++ b/pkg/meta/benchmarks_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/juicedata/juicefs/pkg/utils" + + "github.com/sirupsen/logrus" ) const ( @@ -32,11 +34,10 @@ const ( tkvAddr = "tikv://127.0.0.1:2379/juicefs" ) -/* func init() { - utils.SetOutFile("bench-test.log") + utils.SetLogLevel(logrus.InfoLevel) + // utils.SetOutFile("bench-test.log") } -*/ func encodeSlices(size int) []string { w := utils.NewBuffer(24) diff --git a/pkg/utils/logger.go b/pkg/utils/logger.go index e7c7e89b80f4..ca161c06f2e5 100644 --- a/pkg/utils/logger.go +++ b/pkg/utils/logger.go @@ -21,6 +21,7 @@ import ( "strings" "sync" + plog "github.com/pingcap/log" "github.com/sirupsen/logrus" ) @@ -108,6 +109,24 @@ func SetLogLevel(lvl logrus.Level) { for _, logger := range loggers { logger.Level = lvl } + var plvl string // TiKV (PingCap) uses uber-zap logging, make it less verbose + switch lvl { + case logrus.TraceLevel: + plvl = "debug" + case logrus.DebugLevel: + plvl = "info" + case logrus.InfoLevel: + fallthrough + case logrus.WarnLevel: + plvl = "warn" + case logrus.ErrorLevel: + plvl = "error" + default: + plvl = "dpanic" + } + conf := &plog.Config{Level: plvl} + l, p, _ := plog.InitLogger(conf) + plog.ReplaceGlobals(l, p) } func SetOutFile(name string) {