Skip to content

Commit

Permalink
Chore: aggregate logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Dec 20, 2019
1 parent eae06a4 commit dd61e8d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions config/initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
Expand Down
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions rules/geoip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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())
}
})

Expand Down

0 comments on commit dd61e8d

Please sign in to comment.