wip: 完成 client api 分析
This commit is contained in:
46
internal/log/log.go
Normal file
46
internal/log/log.go
Normal file
@ -0,0 +1,46 @@
|
||||
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 fmt.Sprintf("%s | %s", uuid.Must(uuid.NewV7()).String(), 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) {
|
||||
ulog.Debug(_mix(ctx, msg), data...)
|
||||
}
|
||||
|
||||
func Info(ctx context.Context, msg string, data ...any) {
|
||||
ulog.Info(_mix(ctx, msg), data...)
|
||||
}
|
||||
|
||||
func Warn(ctx context.Context, msg string, data ...any) {
|
||||
ulog.Warn(_mix(ctx, msg), data...)
|
||||
}
|
||||
|
||||
func Error(ctx context.Context, msg string, data ...any) {
|
||||
ulog.Error(_mix(ctx, msg), data...)
|
||||
}
|
||||
|
||||
func Panic(ctx context.Context, msg string, data ...any) {
|
||||
ulog.Panic(_mix(ctx, msg), data...)
|
||||
}
|
||||
|
||||
func Fatal(ctx context.Context, msg string, data ...any) {
|
||||
ulog.Fatal(_mix(ctx, msg), data...)
|
||||
}
|
Reference in New Issue
Block a user