日志打印问题

This commit is contained in:
lingxin 2025-03-19 16:33:47 +08:00
parent b614642953
commit 0627ea4b56
2 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package lxzap
import (
"context"
"fmt"
"net"
"net/http"
@ -152,8 +153,8 @@ func GinRecovery(stack bool) gin.HandlerFunc {
}
}
func Log(msg any, c *gin.Context) {
v, _ := c.Get("X-Span-ID")
func Log(msg any, ctx context.Context) {
v := ctx.Value("X-Span-ID")
spanId := fmt.Sprintf("%v", v)
//zap.L().Info(`spanId:"` + spanId + `"log:` + msg)
zap.L().Info("fmt",

View File

@ -23,9 +23,11 @@ type Logger struct {
func NewGormZap(zapLogger *zap.Logger) Logger {
return Logger{
ZapLogger: zapLogger,
LogLevel: gormlogger.Warn,
SlowThreshold: 1000 * time.Millisecond,
ZapLogger: zapLogger,
//LogLevel: gormlogger.Warn,
//SlowThreshold: 1000 * time.Millisecond,
LogLevel: gormlogger.Info,
SlowThreshold: 200 * time.Millisecond,
SkipCallerLookup: false,
IgnoreRecordNotFoundError: true,
}