增加时间戳
This commit is contained in:
parent
a1b4fe772c
commit
9b838fd5d9
@ -37,6 +37,7 @@ type LogInfo struct {
|
||||
Result interface{} `json:"result,omitempty"` // 结果,返回值,传指针,如果是报错,传err
|
||||
ErrStr string `json:"err_str,omitempty"` // 错误信息,不用传入,自动记录
|
||||
At string `json:"at"` // 记录时间,不用传入,自动记录
|
||||
Timestamp int64 `json:"timestamp"` // 时间戳,不用传入,自动记录
|
||||
}
|
||||
|
||||
type OperatorType = string
|
||||
@ -84,6 +85,7 @@ func ZapFatal(logger *zap.Logger, log *LogInfo) {
|
||||
|
||||
func handleLog(log *LogInfo) {
|
||||
log.At = carbon.Now().ToDateTimeString()
|
||||
log.Timestamp = carbon.Now().Timestamp()
|
||||
if _, ok := log.Result.(error); ok {
|
||||
log.ErrStr = fmt.Sprintf("%+v", log.Result)
|
||||
log.Result = nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user