package uzone import ( "context" "sync" "github.com/google/uuid" "github.com/loveuer/uzone/pkg/api" "github.com/loveuer/uzone/pkg/log" ) type uzone_logger struct { ctx context.Context } var uzone_logger_pool = &sync.Pool{ New: func() any { return &uzone_logger{} }, } func (ul *uzone_logger) Debug(msg string, data ...any) { traceId, ok := ul.ctx.Value(api.TraceKey).(string) if !ok { traceId = uuid.Must(uuid.NewV7()).String() } log.Debug(traceId+" | "+msg, data...) uzone_logger_pool.Put(ul) } func (ul *uzone_logger) Info(msg string, data ...any) { traceId, ok := ul.ctx.Value(api.TraceKey).(string) if !ok { traceId = uuid.Must(uuid.NewV7()).String() } log.Info(traceId+" | "+msg, data...) uzone_logger_pool.Put(ul) } func (ul *uzone_logger) Warn(msg string, data ...any) { traceId, ok := ul.ctx.Value(api.TraceKey).(string) if !ok { traceId = uuid.Must(uuid.NewV7()).String() } log.Warn(traceId+" | "+msg, data...) uzone_logger_pool.Put(ul) } func (ul *uzone_logger) Error(msg string, data ...any) { traceId, ok := ul.ctx.Value(api.TraceKey).(string) if !ok { traceId = uuid.Must(uuid.NewV7()).String() } log.Error(traceId+" | "+msg, data...) uzone_logger_pool.Put(ul) } func (ul *uzone_logger) Panic(msg string, data ...any) { traceId, ok := ul.ctx.Value(api.TraceKey).(string) if !ok { traceId = uuid.Must(uuid.NewV7()).String() } log.Panic(traceId+" | "+msg, data...) } func (ul *uzone_logger) Fatal(msg string, data ...any) { traceId, ok := ul.ctx.Value(api.TraceKey).(string) if !ok { traceId = uuid.Must(uuid.NewV7()).String() } log.Fatal(traceId+" | "+msg, data...) uzone_logger_pool.Put(ul) }