package log
import "github.com/opentracing/opentracing-go/log"
Index ¶
- type Encoder
- type Field
- func Bool(key string, val bool) Field
- func Error(err error) Field
- func Event(val string) Field
- func Float32(key string, val float32) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func InterleavedKVToFields(keyValues ...interface{}) ([]Field, error)
- func Lazy(ll LazyLogger) Field
- func Message(val string) Field
- func Noop() Field
- func Object(key string, obj interface{}) Field
- func String(key, val string) Field
- func Uint32(key string, val uint32) Field
- func Uint64(key string, val uint64) Field
- func (lf Field) Key() string
- func (lf Field) Marshal(visitor Encoder)
- func (lf Field) String() string
- func (lf Field) Value() interface{}
- type LazyLogger
Types ¶
type Encoder ¶
type Encoder interface { EmitString(key, value string) EmitBool(key string, value bool) EmitInt(key string, value int) EmitInt32(key string, value int32) EmitInt64(key string, value int64) EmitUint32(key string, value uint32) EmitUint64(key string, value uint64) EmitFloat32(key string, value float32) EmitFloat64(key string, value float64) EmitObject(key string, value interface{}) EmitLazyLogger(value LazyLogger) }
Encoder allows access to the contents of a Field (via a call to Field.Marshal).
Tracer implementations typically provide an implementation of Encoder; OpenTracing callers typically do not need to concern themselves with it.
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field instances are constructed via LogBool, LogString, and so on. Tracing implementations may then handle them via the Field.Marshal method.
"heavily influenced by" (i.e., partially stolen from) https://github.com/uber-go/zap
func Bool ¶
Bool adds a bool-valued key:value pair to a Span.LogFields() record
func Error ¶
Error adds an error with the key "error.object" to a Span.LogFields() record
func Event ¶
Event creates a string-valued Field for span logs with key="event" and value=val.
func Float32 ¶
Float32 adds a float32-valued key:value pair to a Span.LogFields() record
func Float64 ¶
Float64 adds a float64-valued key:value pair to a Span.LogFields() record
func Int ¶
Int adds an int-valued key:value pair to a Span.LogFields() record
func Int32 ¶
Int32 adds an int32-valued key:value pair to a Span.LogFields() record
func Int64 ¶
Int64 adds an int64-valued key:value pair to a Span.LogFields() record
func InterleavedKVToFields ¶
InterleavedKVToFields converts keyValues a la Span.LogKV() to a Field slice a la Span.LogFields().
func Lazy ¶
func Lazy(ll LazyLogger) Field
Lazy adds a LazyLogger to a Span.LogFields() record; the tracing implementation will call the LazyLogger function at an indefinite time in the future (after Lazy() returns).
func Message ¶
Message creates a string-valued Field for span logs with key="message" and value=val.
func Noop ¶
func Noop() Field
Noop creates a no-op log field that should be ignored by the tracer. It can be used to capture optional fields, for example those that should only be logged in non-production environment:
func customerField(order *Order) log.Field { if os.Getenv("ENVIRONMENT") == "dev" { return log.String("customer", order.Customer.ID) } return log.Noop() } span.LogFields(log.String("event", "purchase"), customerField(order))
func Object ¶
Object adds an object-valued key:value pair to a Span.LogFields() record Please pass in an immutable object, otherwise there may be concurrency issues. Such as passing in the map, log.Object may result in "fatal error: concurrent map iteration and map write". Because span is sent asynchronously, it is possible that this map will also be modified.
func String ¶
String adds a string-valued key:value pair to a Span.LogFields() record
func Uint32 ¶
Uint32 adds a uint32-valued key:value pair to a Span.LogFields() record
func Uint64 ¶
Uint64 adds a uint64-valued key:value pair to a Span.LogFields() record
func (Field) Key ¶
Key returns the field's key.
func (Field) Marshal ¶
Marshal passes a Field instance through to the appropriate field-type-specific method of an Encoder.
func (Field) String ¶
String returns a string representation of the key and value.
func (Field) Value ¶
func (lf Field) Value() interface{}
Value returns the field's value as interface{}.
type LazyLogger ¶
type LazyLogger func(fv Encoder)
LazyLogger allows for user-defined, late-bound logging of arbitrary data
Source Files ¶
- Version
- v1.2.0 (latest)
- Published
- Jul 1, 2020
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 2 weeks ago –
Tools for package owners.