41 lines
844 B
Go
Raw Normal View History

2024-07-11 16:37:26 +08:00
package log
import (
2024-07-17 23:05:23 +08:00
"context"
2024-07-11 16:37:26 +08:00
"fmt"
"github.com/loveuer/nf"
ulog "github.com/loveuer/nf/nft/log"
)
2024-07-17 23:05:23 +08:00
func _mix(ctx context.Context, msg string) string {
if ctx == nil {
2024-07-11 16:37:26 +08:00
return msg
}
2024-07-17 23:05:23 +08:00
return fmt.Sprintf("%v | %s", ctx.Value(nf.TraceKey), msg)
2024-07-11 16:37:26 +08:00
}
2024-07-17 23:05:23 +08:00
func Debug(ctx context.Context, msg string, data ...any) {
ulog.Debug(_mix(ctx, msg), data...)
2024-07-11 16:37:26 +08:00
}
2024-07-17 23:05:23 +08:00
func Info(ctx context.Context, msg string, data ...any) {
ulog.Info(_mix(ctx, msg), data...)
2024-07-11 16:37:26 +08:00
}
2024-07-17 23:05:23 +08:00
func Warn(ctx context.Context, msg string, data ...any) {
ulog.Warn(_mix(ctx, msg), data...)
2024-07-11 16:37:26 +08:00
}
2024-07-17 23:05:23 +08:00
func Error(ctx context.Context, msg string, data ...any) {
ulog.Error(_mix(ctx, msg), data...)
2024-07-11 16:37:26 +08:00
}
2024-07-17 23:05:23 +08:00
func Panic(ctx context.Context, msg string, data ...any) {
ulog.Panic(_mix(ctx, msg), data...)
2024-07-11 16:37:26 +08:00
}
2024-07-17 23:05:23 +08:00
func Fatal(ctx context.Context, msg string, data ...any) {
ulog.Fatal(_mix(ctx, msg), data...)
2024-07-11 16:37:26 +08:00
}