forked from TrueCloudLab/frostfs-node
35 lines
1 KiB
Go
35 lines
1 KiB
Go
package logger
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing"
|
|
qos "git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (l *Logger) Debug(ctx context.Context, msg string, fields ...zap.Field) {
|
|
l.z.Debug(msg, appendContext(ctx, fields...)...)
|
|
}
|
|
|
|
func (l *Logger) Info(ctx context.Context, msg string, fields ...zap.Field) {
|
|
l.z.Info(msg, appendContext(ctx, fields...)...)
|
|
}
|
|
|
|
func (l *Logger) Warn(ctx context.Context, msg string, fields ...zap.Field) {
|
|
l.z.Warn(msg, appendContext(ctx, fields...)...)
|
|
}
|
|
|
|
func (l *Logger) Error(ctx context.Context, msg string, fields ...zap.Field) {
|
|
l.z.Error(msg, appendContext(ctx, fields...)...)
|
|
}
|
|
|
|
func appendContext(ctx context.Context, fields ...zap.Field) []zap.Field {
|
|
if traceID := tracing.GetTraceID(ctx); traceID != "" {
|
|
fields = append(fields, zap.String("trace_id", traceID))
|
|
}
|
|
if ioTag, ioTagDefined := qos.IOTagFromContext(ctx); ioTagDefined {
|
|
fields = append(fields, zap.String("io_tag", ioTag))
|
|
}
|
|
return fields
|
|
}
|