日志初步结构

This commit is contained in:
2024-04-15 16:08:17 +08:00
parent 16967381d8
commit de7cd23deb
16 changed files with 414 additions and 68 deletions

View File

@@ -8,7 +8,8 @@ type ErrorCode struct {
var (
ErrRespNotNil = &ErrorCode{Code: 10000, Message: "resp must not nil"}
ErrEncGcm = &ErrorCode{Code: 10001, Message: "gmc加密错误"}
ErrEncGcm = &ErrorCode{Code: 10001, Message: "gmc加密错误"}
ErrJSONUnMarshal = &ErrorCode{Code: 10002, Message: "json 解析错误"}
ErrParamParse = &ErrorCode{Code: 10100, Message: "参数解析错误"}

View File

@@ -1,6 +1,9 @@
package basic
import "reflect"
import (
"reflect"
"strings"
)
func GetLangString(param any) string {
// 获取参数的反射值
@@ -18,10 +21,11 @@ func GetLangString(param any) string {
// 如果字段存在并且是字符串类型
if langField.IsValid() && langField.Kind() == reflect.String {
return langField.String()
return strings.TrimSpace(langField.String())
}
}
// 如果无法获取有效的字符串值则返回zh_cn
return "zh_cn"
}

View File

@@ -37,6 +37,7 @@ func (resp *Response) ErrorErr(Code int, err error, Data ...interface{}) *Respon
resp.ErrorText = err.Error()
resp.IsSuccess = false
resp.setData(Data)
log.Error(resp.ErrorText)
return resp
}