From dd61e8d19dad69a7fa1e838f718c79eed3483e0d Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Fri, 20 Dec 2019 17:22:24 +0800 Subject: [PATCH] Chore: aggregate logger --- config/initial.go | 7 +++---- main.go | 7 +++---- rules/geoip.go | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/initial.go b/config/initial.go index cf61d1bc..63ff427f 100644 --- a/config/initial.go +++ b/config/initial.go @@ -10,8 +10,7 @@ import ( "strings" C "github.com/Dreamacro/clash/constant" - - log "github.com/sirupsen/logrus" + "github.com/Dreamacro/clash/log" ) func downloadMMDB(path string) (err error) { @@ -65,13 +64,13 @@ func Init(dir string) error { // initial config.yaml if _, err := os.Stat(C.Path.Config()); os.IsNotExist(err) { - log.Info("Can't find config, create an empty file") + log.Infoln("Can't find config, create an empty file") os.OpenFile(C.Path.Config(), os.O_CREATE|os.O_WRONLY, 0644) } // initial mmdb if _, err := os.Stat(C.Path.MMDB()); os.IsNotExist(err) { - log.Info("Can't find MMDB, start download") + log.Infoln("Can't find MMDB, start download") err := downloadMMDB(C.Path.MMDB()) if err != nil { return fmt.Errorf("Can't download MMDB: %s", err.Error()) diff --git a/main.go b/main.go index a08a5eb5..9e545e02 100644 --- a/main.go +++ b/main.go @@ -12,8 +12,7 @@ import ( "github.com/Dreamacro/clash/config" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/hub" - - log "github.com/sirupsen/logrus" + "github.com/Dreamacro/clash/log" ) var ( @@ -55,11 +54,11 @@ func main() { } if err := config.Init(C.Path.HomeDir()); err != nil { - log.Fatalf("Initial configuration directory error: %s", err.Error()) + log.Fatalln("Initial configuration directory error: %s", err.Error()) } if err := hub.Parse(); err != nil { - log.Fatalf("Parse config error: %s", err.Error()) + log.Fatalln("Parse config error: %s", err.Error()) } sigCh := make(chan os.Signal, 1) diff --git a/rules/geoip.go b/rules/geoip.go index 56b75fea..4b9029cf 100644 --- a/rules/geoip.go +++ b/rules/geoip.go @@ -4,9 +4,9 @@ import ( "sync" C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/clash/log" "github.com/oschwald/geoip2-golang" - log "github.com/sirupsen/logrus" ) var ( @@ -50,7 +50,7 @@ func NewGEOIP(country string, adapter string, noResolveIP bool) *GEOIP { var err error mmdb, err = geoip2.Open(C.Path.MMDB()) if err != nil { - log.Fatalf("Can't load mmdb: %s", err.Error()) + log.Fatalln("Can't load mmdb: %s", err.Error()) } })