@@ -138,7 +138,11 @@ type (
138
138
fieldsFromCtxCallMetaFn func (ctx context.Context , c interceptors.CallMeta ) Fields
139
139
)
140
140
141
- // WithFieldsFromContext allows overriding existing or adding extra fields to all log messages per given context
141
+ // WithFieldsFromContext allows overriding existing or adding extra fields to all log messages per given context.
142
+ // If called multiple times, it overwrites the existing FieldsFromContext/WithFieldsFromContextAndCallMeta function.
143
+ // If you need to use multiple FieldsFromContext functions then you should combine them in a wrapper fieldsFromCtxFn.
144
+ // Only one of WithFieldsFromContextAndCallMeta or WithFieldsFromContext should
145
+ // be used, using both will result in the last one overwriting the previous.
142
146
func WithFieldsFromContext (f fieldsFromCtxFn ) Option {
143
147
return func (o * options ) {
144
148
o .fieldsFromCtxCallMetaFn = func (ctx context.Context , _ interceptors.CallMeta ) Fields {
@@ -148,6 +152,10 @@ func WithFieldsFromContext(f fieldsFromCtxFn) Option {
148
152
}
149
153
150
154
// WithFieldsFromContextAndCallMeta allows overriding existing or adding extra fields to all log messages per given context and interceptor.CallMeta
155
+ // If called multiple times, it overwrites the existing FieldsFromContext/WithFieldsFromContextAndCallMeta function.
156
+ // If you need to use multiple WithFieldsFromContextAndCallMeta functions then you should combine them in a wrapper fieldsFromCtxCallMetaFn.
157
+ // Only one of WithFieldsFromContextAndCallMeta or WithFieldsFromContext should
158
+ // be used, using both will result in the last one overwriting the previous.
151
159
func WithFieldsFromContextAndCallMeta (f fieldsFromCtxCallMetaFn ) Option {
152
160
return func (o * options ) {
153
161
o .fieldsFromCtxCallMetaFn = f
0 commit comments