From 83c46068c741d9c38c05386a3db91a97a6e1aa1e Mon Sep 17 00:00:00 2001 From: Revincx Date: Sun, 16 Oct 2022 10:46:46 +0800 Subject: [PATCH] improve: error log when login fails --- controllers/guardian.go | 2 +- v1/login.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/controllers/guardian.go b/controllers/guardian.go index 49890c9..de11e9d 100644 --- a/controllers/guardian.go +++ b/controllers/guardian.go @@ -31,7 +31,7 @@ func Guardian() { if global.Config.Settings.Basic.Interfaces == "" { //单网卡 e := Login(nil) if e != nil { - log.Errorln("登陆失败: ", e) + log.Errorln("错误: ", e) } } else { //多网卡 interfaces, e := util.GetInterfaceAddr() diff --git a/v1/login.go b/v1/login.go index 5132e86..dad7ff5 100644 --- a/v1/login.go +++ b/v1/login.go @@ -2,7 +2,6 @@ package BitSrun import ( "encoding/json" - "errors" "github.com/Mmx233/BitSrunLoginGo/global" "github.com/Mmx233/BitSrunLoginGo/util" @@ -119,9 +118,11 @@ func Login(c *srunTransfer.Login) error { } G.LoginResult = result.(string) - log.Infoln("登录结果: " + G.LoginResult) - if G.LoginResult != "ok" { - return errors.New(G.LoginResult) + if G.LoginResult == "ok" { + log.Infoln("已成功登录~") + } else { + log.Errorln("登陆失败: ", e) + return nil } }