refactor: remove slient mode and improve debug level log output
This commit is contained in:
@@ -37,9 +37,7 @@ func Guardian() {
|
||||
interfaces, e := util.GetInterfaceAddr()
|
||||
if e == nil {
|
||||
for _, eth := range interfaces {
|
||||
if !global.Config.Settings.Log.SlientMode {
|
||||
log.Infoln("登录使用的网口: " + eth.Name)
|
||||
}
|
||||
log.Debugln("登录使用的网口: " + eth.Name)
|
||||
e = Login(eth.Addr)
|
||||
if e != nil {
|
||||
log.Errorln("网口 ", eth.Name+" 登录失败: ", e)
|
||||
|
||||
2
main.go
2
main.go
@@ -25,7 +25,7 @@ func main() {
|
||||
log.Debugln("多网卡模式")
|
||||
interfaces, _ := util.GetInterfaceAddr()
|
||||
for _, eth := range interfaces {
|
||||
log.Infoln("网卡: ", eth.Name)
|
||||
log.Debugln("使用网卡: ", eth.Name)
|
||||
if err = controllers.Login(eth.Addr); err != nil {
|
||||
log.Errorln("运行出错,状态异常: ", err)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ type Basic struct {
|
||||
|
||||
type Log struct {
|
||||
DebugLevel bool `json:"debug_level" yaml:"debug_level" mapstructure:"debug_level"`
|
||||
SlientMode bool `json:"slient_mode" yaml:"slient_mode" mapstructure:"slient_mode"`
|
||||
WriteFile bool `json:"write_file" yaml:"write_file" mapstructure:"write_file"`
|
||||
FilePath string `json:"log_path" yaml:"log_path" mapstructure:"log_path"`
|
||||
FileName string `json:"log_name" yaml:"log_name" mapstructure:"log_name"`
|
||||
|
||||
22
v1/login.go
22
v1/login.go
@@ -3,7 +3,6 @@ package BitSrun
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/Mmx233/BitSrunLoginGo/global"
|
||||
"github.com/Mmx233/BitSrunLoginGo/util"
|
||||
srunTransfer "github.com/Mmx233/BitSrunLoginGo/v1/transfer"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -11,7 +10,6 @@ import (
|
||||
|
||||
func Login(c *srunTransfer.Login) error {
|
||||
G := util.GenerateLoginInfo(c.LoginInfo.Form, c.LoginInfo.Meta)
|
||||
slientMode := global.Config.Settings.Log.SlientMode
|
||||
api := SrunApi{
|
||||
BaseUrl: func() string {
|
||||
url := "http"
|
||||
@@ -26,25 +24,19 @@ func Login(c *srunTransfer.Login) error {
|
||||
var ok bool
|
||||
|
||||
{
|
||||
if !slientMode {
|
||||
log.Infoln("正在检查登录状态")
|
||||
}
|
||||
log.Debugln("正在检查登录状态")
|
||||
res, e := api.GetUserInfo()
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
err := res["error"].(string)
|
||||
if err == "ok" {
|
||||
if !slientMode {
|
||||
log.Infoln("用户已登录~")
|
||||
}
|
||||
log.Debugln("用户已登录~")
|
||||
return nil
|
||||
}
|
||||
log.Infoln("检测到用户未登录,开始尝试登录...")
|
||||
|
||||
if !slientMode {
|
||||
log.Infoln("正在获取客户端 IP")
|
||||
}
|
||||
log.Debugln("正在获取客户端 IP")
|
||||
var ip interface{}
|
||||
ip, ok = res["client_ip"]
|
||||
if !ok {
|
||||
@@ -57,9 +49,7 @@ func Login(c *srunTransfer.Login) error {
|
||||
log.Debugln("ip: ", G.Ip)
|
||||
}
|
||||
|
||||
if !slientMode {
|
||||
log.Infoln("正在获取 Token")
|
||||
}
|
||||
log.Debugln("正在获取 Token")
|
||||
{
|
||||
res, e := api.GetChallenge(G.Form.UserName, G.Ip)
|
||||
if e != nil {
|
||||
@@ -74,9 +64,7 @@ func Login(c *srunTransfer.Login) error {
|
||||
log.Debugln("token: ", G.Token)
|
||||
}
|
||||
|
||||
if !slientMode {
|
||||
log.Infoln("发送登录请求")
|
||||
}
|
||||
log.Debugln("发送登录请求")
|
||||
{
|
||||
info, e := json.Marshal(map[string]string{
|
||||
"username": G.Form.UserName,
|
||||
|
||||
Reference in New Issue
Block a user