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

Method TimeDiff

event.go:807–817  ·  view source on GitHub ↗

TimeDiff adds the field key with positive duration between time t and start. If time t is not greater than start, duration will be 0. Duration format follows the same principle as Dur().

(key string, t time.Time, start time.Time)

Source from the content-addressed store, hash-verified

805// If time t is not greater than start, duration will be 0.
806// Duration format follows the same principle as Dur().
807func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event {
808 if e == nil {
809 return e
810 }
811 var d time.Duration
812 if t.After(start) {
813 d = t.Sub(start)
814 }
815 e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldFormat, DurationFieldInteger, FloatingPointPrecision)
816 return e
817}
818
819// Any is a wrapper around Event.Interface.
820func (e *Event) Any(key string, i interface{}) *Event {

Callers 2

TestFieldsFunction · 0.80
TestFieldsDisabledFunction · 0.80

Calls 2

AppendDurationMethod · 0.65
AppendKeyMethod · 0.65

Tested by 2

TestFieldsFunction · 0.64
TestFieldsDisabledFunction · 0.64