feat ✨ 优化logger使用
This commit is contained in:
1 parent
d3fa3ecf6c
commit
e23a1f615f
7 files changed
+24
-25
No files matched your search
@@ -76,7 +76,7 @@ func LoggerToFile() gin.HandlerFunc {
|
||||
"method": reqMethod,
|
||||
"uri": reqUri,
|
||||
}
|
||||
log.Info(logData)
|
||||
log.WithFields(logData).Info()
|
||||
//l := logger.Logger{Logger: log.Fields(logData)}
|
||||
//l.Info(logData)
|
||||
if c.Request.Method != "GET" && c.Request.Method != "OPTIONS" && config.LoggerConfig.EnabledDB {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/go-admin-team/go-admin-core/logger"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -24,6 +26,11 @@ func RequestId(trafficKey string) gin.HandlerFunc {
|
||||
}
|
||||
c.Request.Header.Set(trafficKey, requestId)
|
||||
c.Set(trafficKey, requestId)
|
||||
c.Set(pkg.LoggerKey,
|
||||
logger.NewHelper(logger.DefaultLogger).
|
||||
WithFields(map[string]interface{}{
|
||||
trafficKey: requestId,
|
||||
}))
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user