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

View File

@@ -3,6 +3,7 @@ package util
import (
"github.com/Mmx233/BitSrunLoginGo/global"
srunModels "github.com/Mmx233/BitSrunLoginGo/models"
log "github.com/sirupsen/logrus"
"net"
"regexp"
"strings"
@@ -17,13 +18,13 @@ func GetInterfaceAddr() ([]srunModels.Eth, error) {
}
reg, e := regexp.Compile(global.Config.Settings.Basic.Interfaces)
if e != nil {
Log.Fatal("interfaces设置异常无法解析: ", e)
log.Fatalln("interfaces设置异常无法解析: ", e)
}
for _, eth := range interfaces {
if reg.Match([]byte(eth.Name)) {
addrs, e := eth.Addrs()
if e != nil {
Log.Warn(eth.Name+" 网卡地址获取失败: ", e)
log.Warnln(eth.Name+" 网卡地址获取失败: ", e)
continue
}
for _, addr := range addrs {
@@ -31,7 +32,7 @@ func GetInterfaceAddr() ([]srunModels.Eth, error) {
var ip *net.TCPAddr
ip, e = net.ResolveTCPAddr("tcp", strings.Split(addr.String(), "/")[0]+":0")
if e != nil {
Log.Warn(eth.Name+" ip解析失败", e)
log.Warnln(eth.Name+" ip解析失败", e)
continue
}
result = append(result, srunModels.Eth{