|
|
@ -31,7 +31,10 @@ func AddGlobalFields(fields ...LogField) {
|
|
|
|
func ContextWithFields(ctx context.Context, fields ...LogField) context.Context {
|
|
|
|
func ContextWithFields(ctx context.Context, fields ...LogField) context.Context {
|
|
|
|
if val := ctx.Value(fieldsContextKey); val != nil {
|
|
|
|
if val := ctx.Value(fieldsContextKey); val != nil {
|
|
|
|
if arr, ok := val.([]LogField); ok {
|
|
|
|
if arr, ok := val.([]LogField); ok {
|
|
|
|
return context.WithValue(ctx, fieldsContextKey, append(arr, fields...))
|
|
|
|
allFields := make([]LogField, 0, len(arr)+len(fields))
|
|
|
|
|
|
|
|
allFields = append(allFields, arr...)
|
|
|
|
|
|
|
|
allFields = append(allFields, fields...)
|
|
|
|
|
|
|
|
return context.WithValue(ctx, fieldsContextKey, allFields)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|