ObjectEncoder is a strongly-typed, encoding-agnostic interface for adding a map- or struct-like object to the logging context. Like maps, ObjectEncoders aren't safe for concurrent use (though typical use shouldn't require locks).
| 362 | // map- or struct-like object to the logging context. Like maps, ObjectEncoders |
| 363 | // aren't safe for concurrent use (though typical use shouldn't require locks). |
| 364 | type ObjectEncoder interface { |
| 365 | // Logging-specific marshalers. |
| 366 | AddArray(key string, marshaler ArrayMarshaler) error |
| 367 | AddObject(key string, marshaler ObjectMarshaler) error |
| 368 | |
| 369 | // Built-in types. |
| 370 | AddBinary(key string, value []byte) // for arbitrary bytes |
| 371 | AddByteString(key string, value []byte) // for UTF-8 encoded bytes |
| 372 | AddBool(key string, value bool) |
| 373 | AddComplex128(key string, value complex128) |
| 374 | AddComplex64(key string, value complex64) |
| 375 | AddDuration(key string, value time.Duration) |
| 376 | AddFloat64(key string, value float64) |
| 377 | AddFloat32(key string, value float32) |
| 378 | AddInt(key string, value int) |
| 379 | AddInt64(key string, value int64) |
| 380 | AddInt32(key string, value int32) |
| 381 | AddInt16(key string, value int16) |
| 382 | AddInt8(key string, value int8) |
| 383 | AddString(key, value string) |
| 384 | AddTime(key string, value time.Time) |
| 385 | AddUint(key string, value uint) |
| 386 | AddUint64(key string, value uint64) |
| 387 | AddUint32(key string, value uint32) |
| 388 | AddUint16(key string, value uint16) |
| 389 | AddUint8(key string, value uint8) |
| 390 | AddUintptr(key string, value uintptr) |
| 391 | |
| 392 | // AddReflected uses reflection to serialize arbitrary objects, so it can be |
| 393 | // slow and allocation-heavy. |
| 394 | AddReflected(key string, value interface{}) error |
| 395 | // OpenNamespace opens an isolated namespace where all subsequent fields will |
| 396 | // be added. Applications can use namespaces to prevent key collisions when |
| 397 | // injecting loggers into sub-components or third-party libraries. |
| 398 | OpenNamespace(key string) |
| 399 | } |
| 400 | |
| 401 | // ArrayEncoder is a strongly-typed, encoding-agnostic interface for adding |
| 402 | // array-like objects to the logging context. Of note, it supports mixed-type |
no outgoing calls
no test coverage detected