41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
|
package logger
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing"
|
||
|
"go.uber.org/zap"
|
||
|
)
|
||
|
|
||
|
func (l *Logger) Debug(ctx context.Context, msg string, fields ...zap.Field) {
|
||
|
if traceID := tracing.GetTraceID(ctx); traceID != "" {
|
||
|
l.z.Debug(msg, append(fields, zap.String("trace_id", traceID))...)
|
||
|
return
|
||
|
}
|
||
|
l.z.Debug(msg, fields...)
|
||
|
}
|
||
|
|
||
|
func (l *Logger) Info(ctx context.Context, msg string, fields ...zap.Field) {
|
||
|
if traceID := tracing.GetTraceID(ctx); traceID != "" {
|
||
|
l.z.Info(msg, append(fields, zap.String("trace_id", traceID))...)
|
||
|
return
|
||
|
}
|
||
|
l.z.Info(msg, fields...)
|
||
|
}
|
||
|
|
||
|
func (l *Logger) Warn(ctx context.Context, msg string, fields ...zap.Field) {
|
||
|
if traceID := tracing.GetTraceID(ctx); traceID != "" {
|
||
|
l.z.Warn(msg, append(fields, zap.String("trace_id", traceID))...)
|
||
|
return
|
||
|
}
|
||
|
l.z.Warn(msg, fields...)
|
||
|
}
|
||
|
|
||
|
func (l *Logger) Error(ctx context.Context, msg string, fields ...zap.Field) {
|
||
|
if traceID := tracing.GetTraceID(ctx); traceID != "" {
|
||
|
l.z.Error(msg, append(fields, zap.String("trace_id", traceID))...)
|
||
|
return
|
||
|
}
|
||
|
l.z.Error(msg, fields...)
|
||
|
}
|