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) MarshalJSON() ([]byte, error)
- func (f AttributeField) MarshalYAML() (interface{}, error)
- 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) 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) MarshalJSON() ([]byte, error)
- func (f BodyField) MarshalYAML() (interface{}, error)
- 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) 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) MarshalJSON() ([]byte, error)
- func (f ResourceField) MarshalYAML() (interface{}, error)
- 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) UnmarshalYAML(unmarshal func(interface{}) error) error
- 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 ¶ added in v0.16.0
type AttributeField struct {
Keys []string
}
AttributeField is the path to an entry attribute
func (AttributeField) Child ¶ added in v0.29.0
func (f AttributeField) Child(key string) AttributeField
Child returns a child of the current field using the given key.
func (AttributeField) Delete ¶ added in v0.16.0
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 ¶ added in v0.16.0
func (f AttributeField) Get(entry *Entry) (interface{}, bool)
Get will return the attribute value and a boolean indicating if it exists
func (AttributeField) MarshalJSON ¶ added in v0.29.0
func (f AttributeField) MarshalJSON() ([]byte, error)
MarshalJSON will marshal the field for JSON.
func (AttributeField) MarshalYAML ¶ added in v0.29.0
func (f AttributeField) MarshalYAML() (interface{}, error)
MarshalYAML will marshal the field for YAML.
func (AttributeField) Merge ¶ added in v0.29.0
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 ¶ added in v0.29.0
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 ¶ added in v0.16.0
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 ¶ added in v0.16.0
func (f AttributeField) String() string
String returns the string representation of this field.
func (*AttributeField) UnmarshalJSON ¶ added in v0.29.0
func (f *AttributeField) UnmarshalJSON(raw []byte) error
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*AttributeField) UnmarshalYAML ¶ added in v0.29.0
func (f *AttributeField) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML will attempt to unmarshal a field from YAML.
type BodyField ¶ added in v0.17.0
type BodyField struct {
Keys []string
}
BodyField is a field found on an entry body.
func (BodyField) Child ¶ added in v0.17.0
Child returns a child of the current field using the given key.
func (BodyField) Delete ¶ added in v0.17.0
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 ¶ added in v0.17.0
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) MarshalJSON ¶ added in v0.17.0
MarshalJSON will marshal the field for JSON.
func (BodyField) MarshalYAML ¶ added in v0.17.0
MarshalYAML will marshal the field for YAML.
func (BodyField) Merge ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 ¶ added in v0.17.0
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*BodyField) UnmarshalYAML ¶ added in v0.17.0
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 ¶ added in v0.16.0
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 ¶ added in v0.16.0
NewAttributeField will creat a new attribute field from a key
func NewBodyField ¶ added in v0.17.0
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) MarshalJSON ¶
MarshalJSON will marshal a field into JSON
func (Field) MarshalYAML ¶
MarshalYAML will marshal a field into YAML
func (*Field) UnmarshalJSON ¶
UnmarshalJSON will unmarshal a field from JSON
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 ¶ added in v0.29.0
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) MarshalJSON ¶ added in v0.29.0
func (f ResourceField) MarshalJSON() ([]byte, error)
MarshalJSON will marshal the field for JSON.
func (ResourceField) MarshalYAML ¶ added in v0.29.0
func (f ResourceField) MarshalYAML() (interface{}, error)
MarshalYAML will marshal the field for YAML.
func (ResourceField) Merge ¶ added in v0.29.0
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 ¶ added in v0.29.0
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 ¶ added in v0.29.0
func (f *ResourceField) UnmarshalJSON(raw []byte) error
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*ResourceField) UnmarshalYAML ¶ added in v0.29.0
func (f *ResourceField) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML will attempt to 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 )