Documentation ¶
Index ¶
- Constants
- type AttributeField
- func (f AttributeField) Child(key string) AttributeField
- func (f AttributeField) Delete(entry *Entry) (interface{}, bool)
- func (f AttributeField) Get(entry *Entry) (interface{}, bool)
- func (f AttributeField) Merge(entry *Entry, mapValues map[string]interface{})
- func (f AttributeField) Parent() AttributeField
- func (f AttributeField) Set(entry *Entry, value interface{}) error
- func (f AttributeField) String() string
- func (f *AttributeField) UnmarshalJSON(raw []byte) error
- func (f *AttributeField) UnmarshalText(text []byte) error
- func (f *AttributeField) UnmarshalYAML(unmarshal func(interface{}) error) error
- type BodyField
- func (f BodyField) Child(key string) BodyField
- func (f BodyField) Delete(entry *Entry) (interface{}, bool)
- func (f BodyField) Get(entry *Entry) (interface{}, bool)
- func (f BodyField) Merge(entry *Entry, mapValues map[string]interface{})
- func (f BodyField) Parent() BodyField
- func (f BodyField) Set(entry *Entry, value interface{}) error
- func (f BodyField) String() string
- func (f *BodyField) UnmarshalJSON(raw []byte) error
- func (f *BodyField) UnmarshalText(text []byte) error
- func (f *BodyField) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Entry
- func (entry *Entry) AddAttribute(key, value string)
- func (entry *Entry) AddResourceKey(key, value string)
- func (entry *Entry) Copy() *Entry
- func (entry *Entry) Delete(field FieldInterface) (interface{}, bool)
- func (entry *Entry) Get(field FieldInterface) (interface{}, bool)
- func (entry *Entry) Read(field FieldInterface, dest interface{}) error
- func (entry *Entry) Set(field FieldInterface, val interface{}) error
- type Field
- type FieldInterface
- type NilField
- type ResourceField
- func (f ResourceField) Child(key string) ResourceField
- func (f ResourceField) Delete(entry *Entry) (interface{}, bool)
- func (f ResourceField) Get(entry *Entry) (interface{}, bool)
- func (f ResourceField) Merge(entry *Entry, mapValues map[string]interface{})
- func (f ResourceField) Parent() ResourceField
- func (f ResourceField) Set(entry *Entry, value interface{}) error
- func (f ResourceField) String() string
- func (f *ResourceField) UnmarshalJSON(raw []byte) error
- func (f *ResourceField) UnmarshalText(text []byte) error
- func (f *ResourceField) UnmarshalYAML(unmarshal func(interface{}) error) error
- type RootableField
- type Severity
Constants ¶
const ( AttributesPrefix = "attributes" ResourcePrefix = "resource" BodyPrefix = "body" )
const ( // Begin is the beginning state of a field split Begin splitState = iota // InBracket is the state of a field split inside a bracket InBracket // InQuote is the state of a field split inside a quote InQuote // OutQuote is the state of a field split outside a quote OutQuote // OutBracket is the state of a field split outside a bracket OutBracket // InUnbracketedToken is the state field split on any token outside brackets InUnbracketedToken )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributeField ¶
type AttributeField struct {
Keys []string
}
AttributeField is the path to an entry attribute
func (AttributeField) Child ¶
func (f AttributeField) Child(key string) AttributeField
Child returns a child of the current field using the given key.
func (AttributeField) Delete ¶
func (f AttributeField) Delete(entry *Entry) (interface{}, bool)
Delete removes a value from an entry's attributes using the field. It will return the deleted value and whether the field existed.
func (AttributeField) Get ¶
func (f AttributeField) Get(entry *Entry) (interface{}, bool)
Get will return the attribute value and a boolean indicating if it exists
func (AttributeField) Merge ¶
func (f AttributeField) Merge(entry *Entry, mapValues map[string]interface{})
Merge will attempt to merge the contents of a map into an entry's attributes. It will overwrite any intermediate values as necessary.
func (AttributeField) Parent ¶
func (f AttributeField) Parent() AttributeField
Parent returns the parent of the current field. In the case that the attribute field points to the root node, it is a no-op.
func (AttributeField) Set ¶
func (f AttributeField) Set(entry *Entry, value interface{}) error
Set will set a value on an entry's attributes using the field. If a key already exists, it will be overwritten.
func (AttributeField) String ¶
func (f AttributeField) String() string
String returns the string representation of this field.
func (*AttributeField) UnmarshalJSON ¶
func (f *AttributeField) UnmarshalJSON(raw []byte) error
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*AttributeField) UnmarshalText ¶ added in v0.59.0
func (f *AttributeField) UnmarshalText(text []byte) error
UnmarshalText will unmarshal a field from text
func (*AttributeField) UnmarshalYAML ¶
func (f *AttributeField) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML will attempt to unmarshal a field from YAML.
type BodyField ¶
type BodyField struct {
Keys []string
}
BodyField is a field found on an entry body.
func (BodyField) Delete ¶
Delete removes a value from an entry's body using the field. It will return the deleted value and whether the field existed.
func (BodyField) Get ¶
Get will retrieve a value from an entry's body using the field. It will return the value and whether the field existed.
func (BodyField) Merge ¶
Merge will attempt to merge the contents of a map into an entry's body. It will overwrite any intermediate values as necessary.
func (BodyField) Parent ¶
Parent returns the parent of the current field. In the case that the body field points to the root node, it is a no-op.
func (BodyField) Set ¶
Set will set a value on an entry's body using the field. If a key already exists, it will be overwritten.
func (*BodyField) UnmarshalJSON ¶
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*BodyField) UnmarshalText ¶ added in v0.59.0
UnmarshalText will unmarshal a field from text
func (*BodyField) UnmarshalYAML ¶
UnmarshalYAML will attempt to unmarshal a field from YAML.
type Entry ¶
type Entry struct { ObservedTimestamp time.Time `json:"observed_timestamp" yaml:"observed_timestamp"` Timestamp time.Time `json:"timestamp" yaml:"timestamp"` Body interface{} `json:"body" yaml:"body"` Attributes map[string]interface{} `json:"attributes,omitempty" yaml:"attributes,omitempty"` Resource map[string]interface{} `json:"resource,omitempty" yaml:"resource,omitempty"` SeverityText string `json:"severity_text,omitempty" yaml:"severity_text,omitempty"` SpanID []byte `json:"span_id,omitempty" yaml:"span_id,omitempty"` TraceID []byte `json:"trace_id,omitempty" yaml:"trace_id,omitempty"` TraceFlags []byte `json:"trace_flags,omitempty" yaml:"trace_flags,omitempty"` Severity Severity `json:"severity" yaml:"severity"` ScopeName string `json:"scope_name" yaml:"scope_name"` }
Entry is a flexible representation of log data associated with a timestamp.
func New ¶
func New() *Entry
New will create a new log entry with current timestamp and an empty body.
func (*Entry) AddAttribute ¶
AddAttribute will add a key/value pair to the entry's attributes.
func (*Entry) AddResourceKey ¶
AddResourceKey wil add a key/value pair to the entry's resource.
func (*Entry) Delete ¶
func (entry *Entry) Delete(field FieldInterface) (interface{}, bool)
Delete will delete a field from the entry.
func (*Entry) Get ¶
func (entry *Entry) Get(field FieldInterface) (interface{}, bool)
Get will return the value of a field on the entry, including a boolean indicating if the field exists.
func (*Entry) Read ¶
func (entry *Entry) Read(field FieldInterface, dest interface{}) error
Read will read the value of a field into a designated interface.
func (*Entry) Set ¶
func (entry *Entry) Set(field FieldInterface, val interface{}) error
Set will set the value of a field on the entry.
type Field ¶
type Field struct {
FieldInterface
}
Field represents a potential field on an entry. It is used to get, set, and delete values at this field. It is deserialized from JSON dot notation.
func NewAttributeField ¶
NewAttributeField will creat a new attribute field from a key
func NewBodyField ¶
NewBodyField creates a new field from an ordered array of keys.
func NewResourceField ¶
NewResourceField will creat a new resource field from a key
func (*Field) UnmarshalJSON ¶
UnmarshalJSON will unmarshal a field from JSON
func (*Field) UnmarshalText ¶ added in v0.59.0
UnmarshalText will unmarshal a field from text
func (*Field) UnmarshalYAML ¶
UnmarshalYAML will unmarshal a field from YAML
type FieldInterface ¶
type FieldInterface interface { Get(*Entry) (interface{}, bool) Set(entry *Entry, value interface{}) error Delete(entry *Entry) (interface{}, bool) String() string }
FieldInterface is a field on an entry.
type NilField ¶
type NilField struct{}
NilField is a struct that implements Field, but does nothing for all its operations. It is useful as a default no-op field to avoid nil checks.
type ResourceField ¶
type ResourceField struct {
Keys []string
}
ResourceField is the path to an entry resource
func (ResourceField) Child ¶
func (f ResourceField) Child(key string) ResourceField
Child returns a child of the current field using the given key.
func (ResourceField) Delete ¶
func (f ResourceField) Delete(entry *Entry) (interface{}, bool)
Delete removes a value from an entry's resource using the field. It will return the deleted value and whether the field existed.
func (ResourceField) Get ¶
func (f ResourceField) Get(entry *Entry) (interface{}, bool)
Get will return the resource value and a boolean indicating if it exists
func (ResourceField) Merge ¶
func (f ResourceField) Merge(entry *Entry, mapValues map[string]interface{})
Merge will attempt to merge the contents of a map into an entry's resource. It will overwrite any intermediate values as necessary.
func (ResourceField) Parent ¶
func (f ResourceField) Parent() ResourceField
Parent returns the parent of the current field. In the case that the resource field points to the root node, it is a no-op.
func (ResourceField) Set ¶
func (f ResourceField) Set(entry *Entry, value interface{}) error
Set will set a value on an entry's resource using the field. If a key already exists, it will be overwritten.
func (ResourceField) String ¶
func (f ResourceField) String() string
String returns the string representation of this field.
func (*ResourceField) UnmarshalJSON ¶
func (f *ResourceField) UnmarshalJSON(raw []byte) error
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*ResourceField) UnmarshalText ¶ added in v0.59.0
func (f *ResourceField) UnmarshalText(text []byte) error
UnmarshalText will unmarshal a field from text
func (*ResourceField) UnmarshalYAML ¶
func (f *ResourceField) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML will attempt to unmarshal a field from YAML.
type RootableField ¶ added in v0.61.0
type RootableField struct {
Field
}
RootableField is a Field that may refer directly to "attributes" or "resource"
func (*RootableField) UnmarshalJSON ¶ added in v0.61.0
func (r *RootableField) UnmarshalJSON(raw []byte) error
UnmarshalJSON will unmarshal a field from JSON
func (*RootableField) UnmarshalText ¶ added in v0.61.0
func (r *RootableField) UnmarshalText(text []byte) error
UnmarshalText will unmarshal a field from text
func (*RootableField) UnmarshalYAML ¶ added in v0.61.0
func (r *RootableField) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML will unmarshal a field from YAML
type Severity ¶
type Severity int
Severity indicates the seriousness of a log entry
const ( // Default indicates an unknown severity Default Severity = iota // A fine-grained debugging event. Typically disabled in default configurations. Trace Trace2 Trace3 Trace4 // A debugging event. Debug Debug2 Debug3 Debug4 // An informational event. Indicates that an event happened. Info Info2 Info3 Info4 // A warning event. Not an error but is likely more important than an informational event. Warn Warn2 Warn3 Warn4 // An error event. Something went wrong. Error Error2 Error3 Error4 // An error event. Something went wrong. Fatal Fatal2 Fatal3 Fatal4 )