Skip to content

Commit

Permalink
Update log format and level in project
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunop committed Mar 13, 2024
1 parent d79da5b commit 660b2c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func CheckPassword(username string, password string) (string, error) {
var user User
matched, regErr := regexp.MatchString("@", username)
if regErr != nil {
userLogger.Infof("regexp matchiong error")
userLogger.Errorf("regexp matchiong error")
return "", regErr
}

Expand All @@ -67,7 +67,7 @@ func CheckPassword(username string, password string) (string, error) {
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
userLogger.Infof("User [%s] Not Exist\n", username)
userLogger.Errorf("User [%s] Not Exist\n", username)
return "", result.UserNotExist
}
}
Expand Down Expand Up @@ -95,7 +95,7 @@ func GetUserByEmail(email string) (*User, error) {
err := Db.Where("email = ?", email).Where("is_deleted = ?", false).First(&user).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
userLogger.Infof("User [%s] Not Exist\n", email)
userLogger.Errorf("User [%s] Not Exist\n", email)
return nil, nil
}
return nil, result.InternalErr
Expand All @@ -110,7 +110,7 @@ func GetUserByUid(uid string) (*User, error) {
err := Db.Where("uid = ?", uid).Where("is_deleted = ?", false).First(&user).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
userLogger.Infof("User [%s] Not Exist\n", uid)
userLogger.Errorf("User [%s] Not Exist\n", uid)
return nil, result.UserNotExist
}
return nil, err
Expand All @@ -122,7 +122,7 @@ func UserInfo(username string) (*User, error) {
var user = User{Uid: &username}
matched, err2 := regexp.MatchString("@", username)
if err2 != nil {
userLogger.Infof("regexp matchiong error")
userLogger.Errorf("regexp matchiong error")
return nil, err2
}
var err error = nil
Expand All @@ -133,7 +133,7 @@ func UserInfo(username string) (*User, error) {
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
userLogger.Infof("User [%s] Not Exist\n", username)
userLogger.Errorf("User [%s] Not Exist\n", username)
return nil, err
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func FindUserByGithubId(githubId string) (*User, error) {
err := Db.Where("github_id = ?", githubId).Where("is_deleted = ?", false).First(&user).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
userLogger.Infof("User [%s] Not Exist\n", githubId)
userLogger.Errorf("User [%s] Not Exist\n", githubId)
return nil, nil
}
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ func VerifyAccount(ctx *gin.Context, username, flag string) (string, error) {
// 1 is login
// 2 is resetPassword
if flag == "0" {
log.Log.Debugf("[%s] enter register verify\n", username)
return VerifyAccountRegister(ctx, username)
} else if flag == "1" {
log.Log.Debugf("[%s] enter login verify\n", username)
return VerifyAccountLogin(ctx, username)
} else if flag == "2" {
log.Log.Debugf("[%s] enter resetPWD verify\n", username)
return VerifyAccountResetPWD(ctx, username)
} else {
return "", result.RequestParamError
Expand Down

0 comments on commit 660b2c7

Please sign in to comment.