日志打印问题

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

View File

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