improve: pass logger instead of using global logger
This commit is contained in:
@@ -5,12 +5,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Mmx233/BitSrunLoginGo/tools"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Guardian 守护模式逻辑
|
||||
func Guardian() {
|
||||
log.Infoln("[以守护模式启动]")
|
||||
logger := config.Logger
|
||||
|
||||
logger.Infoln("[以守护模式启动]")
|
||||
|
||||
GuardianDuration := time.Duration(config.Settings.Guardian.Duration) * time.Second
|
||||
|
||||
@@ -20,16 +21,16 @@ func Guardian() {
|
||||
if config.Settings.Basic.Interfaces == "" { //单网卡
|
||||
err := Login(nil, true)
|
||||
if err != nil {
|
||||
log.Errorln("登录出错: ", err)
|
||||
logger.Errorln("登录出错: ", err)
|
||||
}
|
||||
} else { //多网卡
|
||||
interfaces, err := tools.GetInterfaceAddr(config.Settings.Basic.Interfaces)
|
||||
interfaces, err := tools.GetInterfaceAddr(logger, config.Settings.Basic.Interfaces)
|
||||
if err == nil {
|
||||
for _, eth := range interfaces {
|
||||
log.Debugf("使用 %s 网口登录 ", eth.Name)
|
||||
logger.Debugf("使用 %s 网口登录 ", eth.Name)
|
||||
err = Login(ð, true)
|
||||
if err != nil {
|
||||
log.Errorln("网口 ", eth.Name+" 登录出错: ", err)
|
||||
logger.Errorln("网口 ", eth.Name+" 登录出错: ", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user