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

Method Timestamp

event.go:756–762  ·  view source on GitHub ↗

Timestamp adds the current local time as UNIX timestamp to the *Event context with the "time" key. To customize the key name, change zerolog.TimestampFieldName. NOTE: It won't dedupe the "time" key if the *Event (or *Context) has one already.

()

Source from the content-addressed store, hash-verified

754// NOTE: It won't dedupe the "time" key if the *Event (or *Context) has one
755// already.
756func (e *Event) Timestamp() *Event {
757 if e == nil {
758 return e
759 }
760 e.buf = enc.AppendTime(enc.AppendKey(e.buf, TimestampFieldName), TimestampFunc(), TimeFieldFormat)
761 return e
762}
763
764// Time adds the field key with t formatted as string using zerolog.TimeFieldFormat.
765func (e *Event) Time(key string, t time.Time) *Event {

Callers 12

TestEvent_WithNilEventFunction · 0.95
TestContextTimestampFunction · 0.45
TestEventTimestampFunction · 0.45
TestOutputWithTimestampFunction · 0.45
TestResilientMultiWriterFunction · 0.45
BenchmarkLogFieldTypeFunction · 0.45
setupFunction · 0.45
log.goFile · 0.45
writeLogFunction · 0.45
Example_handlerFunction · 0.45

Calls 2

AppendTimeMethod · 0.65
AppendKeyMethod · 0.65

Tested by 10

TestEvent_WithNilEventFunction · 0.76
TestContextTimestampFunction · 0.36
TestEventTimestampFunction · 0.36
TestOutputWithTimestampFunction · 0.36
TestResilientMultiWriterFunction · 0.36
BenchmarkLogFieldTypeFunction · 0.36
setupFunction · 0.36
Example_handlerFunction · 0.36