From 6388d9d44ddf7f300748996df8341fa0a05b5cb3 Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 21 Sep 2024 18:47:38 +0800 Subject: [PATCH] fixed outputing error in ls-config, ls-routes, etc. --- src/main.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main.go b/src/main.go index e17485c..1b0bac2 100755 --- a/src/main.go +++ b/src/main.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "io" "log" "net/http" "os" @@ -35,13 +36,17 @@ func main() { logrus.SetLevel(logrus.DebugLevel) } - logrus.SetFormatter(&logrus.TextFormatter{ - DisableSorting: true, - DisableLevelTruncation: true, - FullTimestamp: true, - ForceColors: true, - TimestampFormat: "01-02 15:04:05", - }) + if args.Command != common.CommandStart { + logrus.SetOutput(io.Discard) + } else { + logrus.SetFormatter(&logrus.TextFormatter{ + DisableSorting: true, + DisableLevelTruncation: true, + FullTimestamp: true, + ForceColors: true, + TimestampFormat: "01-02 15:04:05", + }) + } if args.Command == common.CommandReload { if err := apiUtils.ReloadServer(); err.HasError() { @@ -59,15 +64,15 @@ func main() { err = config.Validate(data).Error() } if err != nil { - l.Fatal("config error: ", err) + log.Fatal("config error: ", err) } - l.Printf("config OK") + log.Print("config OK") return } cfg, err := config.Load() if err.IsFatal() { - l.Fatal(err) + log.Fatal(err) } if args.Command == common.CommandListConfigs {