MCPcopy
hub / github.com/rs/zerolog / Fields

Method Fields

event.go:172–178  ·  view source on GitHub ↗

Fields is a helper function to use a map or slice to set fields using type assertion. Only map[string]interface{} and []interface{} are accepted. []interface{} must alternate string keys and arbitrary values, and extraneous ones are ignored.

(fields interface{})

Source from the content-addressed store, hash-verified

170// Only map[string]interface{} and []interface{} are accepted. []interface{} must
171// alternate string keys and arbitrary values, and extraneous ones are ignored.
172func (e *Event) Fields(fields interface{}) *Event {
173 if e == nil {
174 return e
175 }
176 e.buf = appendFields(e.buf, fields, e.stack, e.ctx, e.ch)
177 return e
178}
179
180// Dict adds the field key with a dict to the event context.
181// Use e.CreateDict() to create the dictionary.

Callers 15

TestEvent_WithNilEventFunction · 0.95
ExampleEvent_Fields_mapFunction · 0.45
TestFieldsMapFunction · 0.45
TestFieldsMap_ArraysFunction · 0.45
TestWithErrFunction · 0.45
TestFieldsErrFunction · 0.45
TestFieldsErrsFunction · 0.45
TestFieldsMapPntFunction · 0.45
TestFieldsMapNilPntFunction · 0.45

Calls 1

appendFieldsFunction · 0.85

Tested by 15

TestEvent_WithNilEventFunction · 0.76
ExampleEvent_Fields_mapFunction · 0.36
TestFieldsMapFunction · 0.36
TestFieldsMap_ArraysFunction · 0.36
TestWithErrFunction · 0.36
TestFieldsErrFunction · 0.36
TestFieldsErrsFunction · 0.36
TestFieldsMapPntFunction · 0.36
TestFieldsMapNilPntFunction · 0.36