chore: 整理 trace 相关 ctx(2)
This commit is contained in:
parent
d08c56093d
commit
19f683caae
@ -3,16 +3,22 @@ package log
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/loveuer/nf"
|
"github.com/loveuer/nf"
|
||||||
ulog "github.com/loveuer/nf/nft/log"
|
ulog "github.com/loveuer/nf/nft/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _mix(ctx context.Context, msg string) string {
|
func _mix(ctx context.Context, msg string) string {
|
||||||
if ctx == nil {
|
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) {
|
func Debug(ctx context.Context, msg string, data ...any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user