chore: 整理 trace 相关 ctx(2)

This commit is contained in:
loveuer 2024-07-18 09:51:20 +08:00
parent d08c56093d
commit 19f683caae

View File

@ -3,16 +3,22 @@ package log
import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/loveuer/nf"
ulog "github.com/loveuer/nf/nft/log"
)
func _mix(ctx context.Context, msg string) string {
if ctx == nil {
return msg
return fmt.Sprintf("%s | %s", uuid.Must(uuid.NewV7()).String(), msg)
}
return fmt.Sprintf("%v | %s", ctx.Value(nf.TraceKey), msg)
traceId := ctx.Value(nf.TraceKey)
if traceId == nil {
return fmt.Sprintf("%s | %s", uuid.Must(uuid.NewV7()).String(), msg)
}
return fmt.Sprintf("%s | %s", traceId, msg)
}
func Debug(ctx context.Context, msg string, data ...any) {