Documentation
¶
Index ¶
- Constants
- type AppendFunc
- type CustomValue
- type DurationFormat
- type Encoder
- type Field
- func Any(key string, value any) Field
- func Bool(key string, value bool) Field
- func Custom(key string, value CustomValue) Field
- func CustomFunc(key string, value any, append func(enc Encoder, key string, value any)) Field
- func Duration(key string, value time.Duration) Field
- func Err(err error) Field
- func Error(key string, err error) Field
- func Float64(key string, value float64) Field
- func Generic[T any](key string, value T, append AppendFunc[T]) Field
- func Int(key string, value int) Field
- func Int64(key string, value int64) Field
- func String(key, value string) Field
- func Time(key string, value time.Time) Field
- func Uint(key string, value uint) Field
- func Uint64(key string, value uint64) Field
- func ValueOf[T Value](key string, value T) Field
- func (f Field) AnyValue() any
- func (f Field) AppendCustom(enc Encoder)
- func (f Field) BoolValue() bool
- func (f Field) DurationValue() time.Duration
- func (f Field) ErrorValue() error
- func (f Field) Float64Value() float64
- func (f Field) Int64Value() int64
- func (f Field) StringValue() string
- func (f Field) TimeValue() time.Time
- func (f Field) Uint64Value() uint64
- type Kind
- type Value
Constants ¶
View Source
const ( TimeKey = "ts" LevelKey = "level" LoggerKey = "logger" MessageKey = "msg" ErrorKey = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendFunc ¶
AppendFunc encodes a typed value as a field.
type CustomValue ¶
type DurationFormat ¶ added in v1.1.0
type DurationFormat uint8
DurationFormat selects how built-in encoders render time.Duration values.
const ( // DurationString renders durations via time.Duration.String ("1.5s"). // This is the zero value and the default. DurationString DurationFormat = iota // DurationNanos renders durations as integer nanoseconds (1500000000). DurationNanos )
type Encoder ¶
type Encoder interface {
String(key, value string)
Bool(key string, value bool)
Int64(key string, value int64)
Uint64(key string, value uint64)
Float64(key string, value float64)
Duration(key string, value time.Duration)
Time(key string, value time.Time)
Error(key string, err error)
Any(key string, value any)
Null(key string)
}
Encoder is the target API for fields.
It is intentionally format-agnostic: JSON, zap, slog, and other backends implement this interface in their own packages.
type Field ¶
Field is a structured logging field.
It is a concrete value type so built-in fields stay on the hot path without interface boxing. Extension points are represented by Custom, ValueOf, and Any.
func Custom ¶
func Custom(key string, value CustomValue) Field
func CustomFunc ¶
func (Field) AppendCustom ¶
func (Field) DurationValue ¶
func (Field) ErrorValue ¶
func (Field) Float64Value ¶
func (Field) Int64Value ¶
func (Field) StringValue ¶
func (Field) Uint64Value ¶
Click to show internal directories.
Click to hide internal directories.