Time constructs a Field with the given key and value. The encoder controls how the time is serialized.
(key string, val time.Time)
| 345 | // Time constructs a Field with the given key and value. The encoder |
| 346 | // controls how the time is serialized. |
| 347 | func Time(key string, val time.Time) Field { |
| 348 | if val.Before(_minTimeInt64) || val.After(_maxTimeInt64) { |
| 349 | return Field{Key: key, Type: zapcore.TimeFullType, Interface: val} |
| 350 | } |
| 351 | return Field{Key: key, Type: zapcore.TimeType, Integer: val.UnixNano(), Interface: val.Location()} |
| 352 | } |
| 353 | |
| 354 | // Timep constructs a field that carries a *time.Time. The returned Field will safely |
| 355 | // and explicitly represent `nil` when appropriate. |