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

Method Durs

event.go:796–802  ·  view source on GitHub ↗

Durs adds the field key with duration d stored as zerolog.DurationFieldUnit. If zerolog.DurationFieldInteger is true, durations are rendered as integer instead of float.

(key string, d []time.Duration)

Source from the content-addressed store, hash-verified

794// If zerolog.DurationFieldInteger is true, durations are rendered as integer
795// instead of float.
796func (e *Event) Durs(key string, d []time.Duration) *Event {
797 if e == nil {
798 return e
799 }
800 e.buf = enc.AppendDurations(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldFormat, DurationFieldInteger, FloatingPointPrecision)
801 return e
802}
803
804// TimeDiff adds the field key with positive duration between time t and start.
805// If time t is not greater than start, duration will be 0.

Callers 12

TestEvent_WithNilEventFunction · 0.95
ExampleEvent_DursFunction · 0.45
ExampleContext_DursFunction · 0.45
TestWithPluralsFunction · 0.45
TestFieldsArrayNilFunction · 0.45
TestFieldsArrayEmptyFunction · 0.45
ExampleEvent_DursFunction · 0.45
ExampleContext_DursFunction · 0.45
BenchmarkLogFieldTypeFunction · 0.45

Calls 2

AppendDurationsMethod · 0.65
AppendKeyMethod · 0.65

Tested by 12

TestEvent_WithNilEventFunction · 0.76
ExampleEvent_DursFunction · 0.36
ExampleContext_DursFunction · 0.36
TestWithPluralsFunction · 0.36
TestFieldsArrayNilFunction · 0.36
TestFieldsArrayEmptyFunction · 0.36
ExampleEvent_DursFunction · 0.36
ExampleContext_DursFunction · 0.36
BenchmarkLogFieldTypeFunction · 0.36