feat: 改用 logrus 输出日志

This commit is contained in:
Mmx233
2022-08-14 20:47:23 +08:00
parent 51e06a1596
commit df87d75aca
14 changed files with 107 additions and 181 deletions

25
main.go
View File

@@ -4,38 +4,29 @@ import (
"github.com/Mmx233/BitSrunLoginGo/controllers"
"github.com/Mmx233/BitSrunLoginGo/global"
"github.com/Mmx233/BitSrunLoginGo/util"
"log"
log "github.com/sirupsen/logrus"
)
func main() {
if e := util.Log.Init(
global.Config.Settings.Debug.Enable,
global.Config.Settings.Debug.WriteLog,
true,
global.Config.Settings.Debug.LogPath,
); e != nil {
log.Fatalln("初始化日志失败: ", e)
}
if global.Flags.RunningDaemon {
//后台挂起模式中
controllers.Guardian(false)
controllers.Guardian()
} else if global.Config.Settings.Guardian.Enable {
//进入守护模式流程
controllers.EnterGuardian()
} else {
//单次登录模式
if global.Config.Settings.Basic.Interfaces == "" { //单网卡
if err := controllers.Login(true, nil); err != nil {
util.Log.Fatal("运行出错,状态异常: ", err)
if err := controllers.Login(nil); err != nil {
log.Fatalln("运行出错,状态异常: ", err)
}
} else { //多网卡
util.Log.Debug("多网卡模式")
log.Debugln("多网卡模式")
interfaces, _ := util.GetInterfaceAddr()
for _, eth := range interfaces {
util.Log.Info("网卡: ", eth.Name)
if err := controllers.Login(true, eth.Addr); err != nil {
util.Log.Warn("运行出错,状态异常: ", err)
log.Infoln("网卡: ", eth.Name)
if err := controllers.Login(eth.Addr); err != nil {
log.Errorln("运行出错,状态异常: ", err)
}
}
}