mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 05:11:17 +08:00
Chore: aggregate logger
This commit is contained in:
parent
eae06a4a7d
commit
dd61e8d19d
@ -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())
|
||||
|
7
main.go
7
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)
|
||||
|
@ -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())
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user