field

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

nolint: exhaustruct

Index

Constants

This section is empty.

Variables

View Source
var ErrUndefined = errors.New("indefined")

Functions

func AppendString added in v0.5.0

func AppendString(dst []byte, in string) []byte

func WithAppendString added in v0.5.0

func WithAppendString(fn func(dst []byte, in string) []byte) func(*BaseEncoder)

func WithDefaultValue added in v0.5.0

func WithDefaultValue(fn func(dst []byte, e Encoder, val Value) []byte) func(*BaseEncoder)

func WithDelimeter added in v0.5.0

func WithDelimeter(in byte) func(*BaseEncoder)

func WithGropuConfig added in v0.5.0

func WithGropuConfig(start, end, deli byte) func(*BaseEncoder)

func WithNullValue added in v0.5.0

func WithNullValue(in string) func(*BaseEncoder)

Types

type BaseEncoder added in v0.5.0

type BaseEncoder struct {
	AppendString func(dst []byte, in string) []byte

	DefaultValue func(dst []byte, e Encoder, val Value) []byte
	// contains filtered or unexported fields
}

func NewEncoder added in v0.5.0

func NewEncoder(opts ...func(*BaseEncoder)) BaseEncoder

func NewEncoderJSON added in v0.5.0

func NewEncoderJSON(opts ...func(*BaseEncoder)) BaseEncoder

func NewEncoderText added in v0.5.0

func NewEncoderText(opts ...func(*BaseEncoder)) BaseEncoder

func (BaseEncoder) AppendArray added in v0.5.0

func (b BaseEncoder) AppendArray(dst []byte, in []Value) []byte

func (BaseEncoder) AppendBool added in v0.5.0

func (b BaseEncoder) AppendBool(dst []byte, val bool) []byte

func (BaseEncoder) AppendBytes added in v0.5.0

func (b BaseEncoder) AppendBytes(dst, in []byte) []byte

func (BaseEncoder) AppendComplex added in v0.5.0

func (b BaseEncoder) AppendComplex(dst []byte, c complex128) []byte

func (BaseEncoder) AppendDelimiter added in v0.5.0

func (b BaseEncoder) AppendDelimiter(dst []byte, deli byte) []byte

func (BaseEncoder) AppendDuration added in v0.5.0

func (b BaseEncoder) AppendDuration(dst []byte, d time.Duration) []byte

func (BaseEncoder) AppendField added in v0.5.0

func (b BaseEncoder) AppendField(dst []byte, field Field) []byte

func (BaseEncoder) AppendFloat added in v0.5.0

func (b BaseEncoder) AppendFloat(dst []byte, f float64, bitSize int) []byte

func (BaseEncoder) AppendGroup added in v0.5.0

func (b BaseEncoder) AppendGroup(dst []byte, fields []Field) []byte

func (BaseEncoder) AppendInt added in v0.5.0

func (b BaseEncoder) AppendInt(dst []byte, val int64) []byte

func (BaseEncoder) AppendKey added in v0.5.0

func (b BaseEncoder) AppendKey(dst []byte, key string, prefix string) []byte

func (BaseEncoder) AppendNull added in v0.5.0

func (b BaseEncoder) AppendNull(dst []byte) []byte

func (BaseEncoder) AppendTime added in v0.5.0

func (b BaseEncoder) AppendTime(dst []byte, t time.Time) []byte

func (BaseEncoder) AppendUint added in v0.5.0

func (b BaseEncoder) AppendUint(dst []byte, u uint64) []byte

func (BaseEncoder) AppendValue added in v0.5.0

func (b BaseEncoder) AppendValue(dst []byte, val Value) []byte

type ClosureFn added in v0.5.0

type ClosureFn func() any

func (ClosureFn) LogValue added in v0.5.0

func (v ClosureFn) LogValue() any

type Encoder

type Encoder interface {
	AppendField(dst []byte, field Field) []byte
	AppendValue(dst []byte, val Value) []byte
}

type Field

type Field struct {
	Key   string
	Value Value
}

Field struct.

func Any

func Any(key string, value any) Field

func Bool

func Bool(key string, value bool) Field

func Boolp

func Boolp(key string, value *bool) Field

func Bools

func Bools(key string, value ...bool) Field

func Bytes

func Bytes(key string, value []byte) Field

func Complex128 added in v0.5.0

func Complex128(key string, value complex128) Field

func Complex128p added in v0.5.0

func Complex128p(key string, value *complex128) Field

func Complex128s added in v0.5.0

func Complex128s(key string, value ...complex128) Field

func Complex64

func Complex64(key string, value complex64) Field

func Complex64p

func Complex64p(key string, value *complex64) Field

func Complex64s

func Complex64s(key string, value ...complex64) Field

func Duration

func Duration(key string, value time.Duration) Field

func Durationp

func Durationp(key string, value *time.Duration) Field

func Durations

func Durations(key string, value ...time.Duration) Field

func Error

func Error(key string, value error) Field

func Errors

func Errors(key string, value ...error) Field

func Float32

func Float32(key string, value float32) Field

func Float32p

func Float32p(key string, value *float32) Field

func Float32s

func Float32s(key string, value ...float32) Field

func Float64

func Float64(key string, value float64) Field

func Float64p

func Float64p(key string, value *float64) Field

func Float64s

func Float64s(key string, value ...float64) Field

func FormatTime

func FormatTime(key, format string, value time.Time) Field

func FormatTimep

func FormatTimep(key, format string, value *time.Time) Field

func FormatTimes

func FormatTimes(key, format string, value ...time.Time) Field

func Groups added in v0.5.0

func Groups(key string, value ...Field) Field

func Int

func Int(key string, value int) Field

func Int16

func Int16(key string, value int16) Field

func Int16p

func Int16p(key string, value *int16) Field

func Int16s

func Int16s(key string, value ...int16) Field

func Int32

func Int32(key string, value int32) Field

func Int32p

func Int32p(key string, value *int32) Field

func Int32s

func Int32s(key string, value ...int32) Field

func Int64

func Int64(key string, value int64) Field

func Int64p

func Int64p(key string, value *int64) Field

func Int64s

func Int64s(key string, value ...int64) Field

func Int8

func Int8(key string, value int8) Field

func Int8p

func Int8p(key string, value *int8) Field

func Int8s

func Int8s(key string, value ...int8) Field

func Intp

func Intp(key string, value *int) Field

func Ints

func Ints(key string, value ...int) Field

func String

func String(key, value string) Field

func Stringp

func Stringp(key string, value *string) Field

func Strings

func Strings(key string, value ...string) Field

func Time

func Time(key string, value time.Time) Field

func Timep

func Timep(key string, value *time.Time) Field

func Times

func Times(key string, value ...time.Time) Field

func Uint

func Uint(key string, value uint) Field

func Uint16

func Uint16(key string, value uint16) Field

func Uint16p

func Uint16p(key string, value *uint16) Field

func Uint16s

func Uint16s(key string, value ...uint16) Field

func Uint32

func Uint32(key string, value uint32) Field

func Uint32p

func Uint32p(key string, value *uint32) Field

func Uint32s

func Uint32s(key string, value ...uint32) Field

func Uint64

func Uint64(key string, value uint64) Field

func Uint64p

func Uint64p(key string, value *uint64) Field

func Uint64s

func Uint64s(key string, value ...uint64) Field

func Uint8

func Uint8(key string, value uint8) Field

func Uint8p

func Uint8p(key string, value *uint8) Field

func Uint8s

func Uint8s(key string, value ...uint8) Field

func Uintp

func Uintp(key string, value *uint) Field

func Uintptr

func Uintptr(key string, value uintptr) Field

func Uintptrp

func Uintptrp(key string, value *uintptr) Field

func Uintptrs

func Uintptrs(key string, value ...uintptr) Field

func Uints

func Uints(key string, value ...uint) Field

func Valuer added in v0.5.0

func Valuer(key string, value LogValuer) Field

func ValuerFn added in v0.5.0

func ValuerFn(key string, value ClosureFn) Field

func (Field) IsKey added in v0.5.3

func (f Field) IsKey(keys ...string) bool

String implent stringer.

func (Field) String

func (f Field) String() string

String implent stringer.

type Fields

type Fields []Field

func (Fields) Any added in v0.5.0

func (f Fields) Any() any

func (Fields) Append

func (f Fields) Append(fields ...Field) Fields

func (Fields) Fields added in v0.5.0

func (f Fields) Fields(fn func(Field) bool)

func (Fields) Len

func (f Fields) Len() int

func (Fields) Set

func (f Fields) Set(idx int, field Field)

type Kind added in v0.5.0

type Kind int
const (
	KindAny        Kind = iota // any
	KindArray                  // array
	KindNil                    // nil
	KindString                 // string
	KindBool                   // bool
	KindInt64                  // int64
	KindUint64                 // uint64
	KindFloat32                // float32
	KindFloat64                // float64
	KindComplex128             // complex128
	KindBinary                 // bytes
	KindDuration               // duration
	KindTime                   // time
	KindError                  // error
	KindGroup                  // group
	KindClosure                // closure
)

func (Kind) MarshalBinary added in v0.5.0

func (l Kind) MarshalBinary() ([]byte, error)

func (Kind) MarshalJSON added in v0.5.0

func (l Kind) MarshalJSON() ([]byte, error)

func (Kind) MarshalText added in v0.5.0

func (l Kind) MarshalText() ([]byte, error)

func (Kind) String added in v0.5.0

func (i Kind) String() string

func (*Kind) UnmarshalBinary added in v0.5.0

func (l *Kind) UnmarshalBinary(in []byte) error

func (*Kind) UnmarshalJSON added in v0.5.0

func (l *Kind) UnmarshalJSON(in []byte) error

func (*Kind) UnmarshalText added in v0.5.0

func (l *Kind) UnmarshalText(in []byte) error

type LogValuer added in v0.5.0

type LogValuer interface {
	LogValue() any
}

type Value

type Value struct {
	Kind Kind
	// contains filtered or unexported fields
}

func AnyValue added in v0.5.0

func AnyValue(v any) Value

AnyValue returns a Value for the supplied value.

func BoolValue added in v0.5.0

func BoolValue(v bool) Value

BoolValue returns a Value for a bool.

func BoolpValue added in v0.5.0

func BoolpValue(value *bool) Value

BoolpValue returns a new Value for a *bool.

func BoolsValue added in v0.5.0

func BoolsValue(values []bool) Value

BoolsValue returns a Value for a []bool.

func BytesValue added in v0.5.0

func BytesValue(value []byte) Value

func ClosureValue added in v0.5.0

func ClosureValue(fn ClosureFn) Value

func Complex128Value added in v0.5.0

func Complex128Value(v complex128) Value

Complex128Value returns a Value for a complex128.

func Complex128pValue added in v0.5.0

func Complex128pValue(v *complex128) Value

Complex128Value returns a Value for a *complex128.

func Complex128sValue added in v0.5.0

func Complex128sValue(values []complex128) Value

Complex128Value returns a Value for a []complex128.

func Complex64sValue added in v0.5.0

func Complex64sValue(values []complex64) Value

Complex64sValue returns a Value for a []complex64.

func DurationValue added in v0.5.0

func DurationValue(v time.Duration) Value

DurationValue returns a Value for a time.Duration.

func DurationpValue added in v0.5.0

func DurationpValue(v *time.Duration) Value

DurationValue returns a Value for a *time.Duration.

func DurationsValue added in v0.5.0

func DurationsValue(values []time.Duration) Value

DurationValue returns a Value for a *time.Duration.

func ErrorValue added in v0.5.0

func ErrorValue(value error) Value

func ErrorsValue added in v0.5.0

func ErrorsValue(value []error) Value

func Float64Value added in v0.5.0

func Float64Value(v float64) Value

Float64Value returns a Value for a floating-point number.

func Float64pValue added in v0.5.0

func Float64pValue(v *float64) Value

Float64Value returns a Value for a floating-points number.

func Float64sValue added in v0.5.0

func Float64sValue(values []float64) Value

Float64Value returns a Value for a floating-points number.

func GroupValue added in v0.5.0

func GroupValue(as ...Field) Value

GroupValue returns a new Value for a list of Fields.

func Int64Value added in v0.5.0

func Int64Value(value int64) Value

Int64Value returns a Value for an int64.

func Int64pValue added in v0.5.0

func Int64pValue(value *int64) Value

Int64sValue returns a Value for an *int64.

func Int64sValue added in v0.5.0

func Int64sValue(value []int64) Value

Int64sValue returns a Value for an []int64.

func NilValue added in v0.5.0

func NilValue() Value

func StringValue added in v0.5.0

func StringValue(value string) Value

StringValue returns a new Value for a string.

func StringpValue added in v0.5.0

func StringpValue(value *string) Value

StringpValue returns a new Value for a *string.

func StringsValue added in v0.5.0

func StringsValue(value []string) Value

StringpValue returns a new Value for a string.

func TimeValue added in v0.5.0

func TimeValue(v time.Time) Value

TimeValue returns a Value for a time.Time.

func TimepValue added in v0.5.0

func TimepValue(v *time.Time) Value

TimepValue returns a Value for a *time.Time.

func TimesValue added in v0.5.0

func TimesValue(values []time.Time) Value

TimesValue returns a Value for a []time.Time.

func Uint64Value added in v0.5.0

func Uint64Value(v uint64) Value

Uint64Value returns a Value for a uint64.

func Uint64pValue added in v0.5.0

func Uint64pValue(v *uint64) Value

Uint64sValue returns a Value for a []uint64.

func Uint64sValue added in v0.5.0

func Uint64sValue(values []uint64) Value

Uint64sValue returns a Value for a []uint64.

func Uint8sValue added in v0.5.0

func Uint8sValue(values []uint8) Value

Uint8sValue returns a Value for a []uint8.

func (Value) Any added in v0.5.0

func (v Value) Any() any

nolint: gocyclo,cyclop

func (Value) AsArray added in v0.5.0

func (v Value) AsArray() Values

func (Value) AsBinary added in v0.5.0

func (v Value) AsBinary() []byte

func (Value) AsBool added in v0.5.0

func (v Value) AsBool() bool

func (Value) AsComplex128 added in v0.5.0

func (v Value) AsComplex128() complex128

func (Value) AsDuration added in v0.5.0

func (v Value) AsDuration() time.Duration

func (Value) AsError added in v0.5.0

func (v Value) AsError() error

func (Value) AsFloat32 added in v0.5.0

func (v Value) AsFloat32() float32

func (Value) AsFloat64 added in v0.5.0

func (v Value) AsFloat64() float64

func (Value) AsGroup added in v0.5.0

func (v Value) AsGroup() Fields

func (Value) AsInt64 added in v0.5.0

func (v Value) AsInt64() int64

func (Value) AsString added in v0.5.0

func (v Value) AsString() string

nolint: forcetypeassert

func (Value) AsTime added in v0.5.0

func (v Value) AsTime() time.Time

func (Value) AsUint added in v0.5.0

func (v Value) AsUint() uint

func (Value) AsUint64 added in v0.5.0

func (v Value) AsUint64() uint64

func (Value) AsUintptr added in v0.5.0

func (v Value) AsUintptr() uintptr

func (Value) Resolve added in v0.5.0

func (v Value) Resolve() any

func (Value) String

func (v Value) String() string

type Values added in v0.5.0

type Values []Value

func (Values) Resolve added in v0.5.0

func (v Values) Resolve() any

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL