完善非成功请求的日志处理
This commit is contained in:
@@ -114,6 +114,11 @@ func useLogger() fiber.Handler {
|
||||
Format: "🚀 ${time} | ${locals:authtype} ${locals:authid} | ${method} ${path} | ${status} | ${latency} | ${error}\n",
|
||||
TimeFormat: "2006-01-02 15:04:05",
|
||||
TimeZone: "Asia/Shanghai",
|
||||
Next: func(c *fiber.Ctx) bool {
|
||||
c.Locals("authtype", auth.PayloadNone.ToStr())
|
||||
c.Locals("authid", 0)
|
||||
return false
|
||||
},
|
||||
Done: func(c *fiber.Ctx, logBytes []byte) {
|
||||
var logStr = strings.TrimPrefix(string(logBytes), "🚀")
|
||||
var logVars = strings.Split(logStr, "|")
|
||||
@@ -147,8 +152,8 @@ func useLogger() fiber.Handler {
|
||||
Error: errStr,
|
||||
Time: core.LocalDateTime(reqTime),
|
||||
}
|
||||
if authType != nil {
|
||||
item.Identity = int32(*authType)
|
||||
if authType != auth.PayloadNone {
|
||||
item.Identity = int32(authType)
|
||||
}
|
||||
if authID != 0 {
|
||||
item.Visitor = int32(authID)
|
||||
|
||||
Reference in New Issue
Block a user