Documentation ¶
Index ¶
- type Endpoints
- type FieldType
- type KeyValue
- func Any(key string, value interface{}) KeyValue
- func Bool(key string, value bool) KeyValue
- func Duration(key string, value time.Duration) KeyValue
- func Error(value error) KeyValue
- func Int(k string, v int) KeyValue
- func Int64(k string, v int64) KeyValue
- func Latency(start time.Time) KeyValue
- func NamedError(key string, value error) KeyValue
- func String(k, v string) KeyValue
- func Stringer(key string, value fmt.Stringer) KeyValue
- func Strings(key string, value []string) KeyValue
- func Version() KeyValue
- func (f KeyValue) AnyValue() interface{}
- func (f KeyValue) BoolValue() bool
- func (f KeyValue) DurationValue() time.Duration
- func (f KeyValue) ErrorValue() error
- func (f KeyValue) Int64Value() int64
- func (f KeyValue) IntValue() int
- func (f KeyValue) Key() string
- func (f KeyValue) String() string
- func (f KeyValue) StringValue() string
- func (f KeyValue) Stringer() fmt.Stringer
- func (f KeyValue) StringsValue() []string
- func (f KeyValue) Type() FieldType
- type Metadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoints ¶
type Endpoints []trace.EndpointInfo
type FieldType ¶
type FieldType int
FieldType indicates type info about the KeyValue. This enum might be extended in future releases. Adapters that don't support some FieldType value should use KeyValue.Fallback() for marshaling.
const ( // InvalidType indicates that KeyValue was not initialized correctly. Adapters // should either ignore such field or issue an error. No value getters should // be called on field with such type. InvalidType FieldType = iota IntType Int64Type StringType BoolType DurationType // StringsType corresponds to []string StringsType ErrorType // AnyType indicates that the KeyValue is untyped. Adapters should use // reflection-based approached to marshal this field. AnyType // StringerType corresponds to fmt.Stringer StringerType )
type KeyValue ¶
type KeyValue struct {
// contains filtered or unexported fields
}
KeyValue represents typed log field (a key-value pair). Adapters should determine KeyValue's type based on Type and use the corresponding getter method to retrieve the value:
switch f.Type() { case logs.IntType: var i int = f.Int() // handle int value case logs.StringType: var s string = f.String() // handle string value //... }
Getter methods must not be called on fields with wrong Type (e.g. calling String() on fields with Type != StringType). KeyValue must not be initialized directly as a struct literal.
func NamedError ¶
NamedError constructs KeyValue with ErrorType
func Stringer ¶
Stringer constructs KeyValue with StringerType. If value is nil, resulting KeyValue will be of AnyType instead of StringerType.
func (KeyValue) AnyValue ¶
func (f KeyValue) AnyValue() interface{}
AnyValue is a value getter for fields with AnyType type
func (KeyValue) DurationValue ¶
DurationValue is a value getter for fields with DurationType type
func (KeyValue) ErrorValue ¶
ErrorValue is a value getter for fields with ErrorType type
func (KeyValue) Int64Value ¶
Int64Value is a value getter for fields with Int64Type type
func (KeyValue) String ¶
Returns default string representation of KeyValue value. It should be used by adapters that don't support f.Type directly.
func (KeyValue) StringValue ¶
StringValue is a value getter for fields with StringType type
func (KeyValue) StringsValue ¶
StringsValue is a value getter for fields with StringsType type