Documentation ¶
Index ¶
- Constants
- type Entry
- func (entry *Entry) AddLabel(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 LabelField
- type NilField
- type RecordField
- func (f RecordField) Child(key string) RecordField
- func (f RecordField) Delete(entry *Entry) (interface{}, bool)
- func (f RecordField) Get(entry *Entry) (interface{}, bool)
- func (f RecordField) MarshalJSON() ([]byte, error)
- func (f RecordField) MarshalYAML() (interface{}, error)
- func (f RecordField) Merge(entry *Entry, mapValues map[string]interface{})
- func (f RecordField) Parent() RecordField
- func (f RecordField) Set(entry *Entry, value interface{}) error
- func (f RecordField) String() string
- func (f *RecordField) UnmarshalJSON(raw []byte) error
- func (f *RecordField) UnmarshalYAML(unmarshal func(interface{}) error) error
- type ResourceField
- type Severity
Constants ¶
const ( // BEGIN is the beginning state of a field split BEGIN splitState = iota // IN_BRACKET is the state of a field split inside a bracket IN_BRACKET // IN_QUOTE is the state of a field split inside a quote IN_QUOTE // OUT_QUOTE is the state of a field split outside a quote OUT_QUOTE // OUT_BRACKET is the state of a field split outside a bracket OUT_BRACKET // IN_UNBRACKETED_TOKEN is the state field split on any token outside brackets IN_UNBRACKETED_TOKEN )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { Timestamp time.Time `json:"timestamp" yaml:"timestamp"` Severity Severity `json:"severity" yaml:"severity"` Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` Resource map[string]string `json:"resource,omitempty" yaml:"resource,omitempty"` Record interface{} `json:"record" yaml:"record"` }
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 record.
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 NewLabelField ¶
NewLabelField will creat a new label field from a key
func NewRecordField ¶
NewRecordField creates a new field from an ordered array of keys.
func NewResourceField ¶ added in v0.9.13
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 LabelField ¶
type LabelField struct {
// contains filtered or unexported fields
}
LabelField is the path to an entry label
func (LabelField) Delete ¶
func (l LabelField) Delete(entry *Entry) (interface{}, bool)
Delete will delete a label from an entry
func (LabelField) Get ¶
func (l LabelField) Get(entry *Entry) (interface{}, bool)
Get will return the label value and a boolean indicating if it exists
func (LabelField) Set ¶
func (l LabelField) Set(entry *Entry, val interface{}) error
Set will set the label value on an entry
func (LabelField) String ¶
func (l LabelField) String() string
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 RecordField ¶
type RecordField struct {
Keys []string
}
RecordField is a field found on an entry record.
func (RecordField) Child ¶
func (f RecordField) Child(key string) RecordField
Child returns a child of the current field using the given key.
func (RecordField) Delete ¶
func (f RecordField) Delete(entry *Entry) (interface{}, bool)
Delete removes a value from an entry's record using the field. It will return the deleted value and whether the field existed.
func (RecordField) Get ¶
func (f RecordField) Get(entry *Entry) (interface{}, bool)
Get will retrieve a value from an entry's record using the field. It will return the value and whether the field existed.
func (RecordField) MarshalJSON ¶
func (f RecordField) MarshalJSON() ([]byte, error)
MarshalJSON will marshal the field for JSON.
func (RecordField) MarshalYAML ¶
func (f RecordField) MarshalYAML() (interface{}, error)
MarshalYAML will marshal the field for YAML.
func (RecordField) Merge ¶
func (f RecordField) Merge(entry *Entry, mapValues map[string]interface{})
Merge will attempt to merge the contents of a map into an entry's record. It will overwrite any intermediate values as necessary.
func (RecordField) Parent ¶
func (f RecordField) Parent() RecordField
Parent returns the parent of the current field. In the case that the record field points to the root node, it is a no-op.
func (RecordField) Set ¶
func (f RecordField) Set(entry *Entry, value interface{}) error
Set will set a value on an entry's record using the field. If a key already exists, it will be overwritten. If mergeMaps is set to true, map values will be merged together.
func (RecordField) String ¶
func (f RecordField) String() string
String returns the string representation of this field.
func (*RecordField) UnmarshalJSON ¶
func (f *RecordField) UnmarshalJSON(raw []byte) error
UnmarshalJSON will attempt to unmarshal the field from JSON.
func (*RecordField) UnmarshalYAML ¶
func (f *RecordField) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML will attempt to unmarshal a field from YAML.
type ResourceField ¶ added in v0.9.13
type ResourceField struct {
// contains filtered or unexported fields
}
ResourceField is the path to an entry's resource key
func (ResourceField) Delete ¶ added in v0.9.13
func (r ResourceField) Delete(entry *Entry) (interface{}, bool)
Delete will delete a resource key from an entry
func (ResourceField) Get ¶ added in v0.9.13
func (r ResourceField) Get(entry *Entry) (interface{}, bool)
Get will return the resource value and a boolean indicating if it exists
func (ResourceField) Set ¶ added in v0.9.13
func (r ResourceField) Set(entry *Entry, val interface{}) error
Set will set the resource value on an entry
func (ResourceField) String ¶ added in v0.9.13
func (r ResourceField) String() string
type Severity ¶
type Severity int
Severity indicates the seriousness of a log entry
const ( // Default indicates an unknown severity Default Severity = 0 // Trace indicates that the log may be useful for detailed debugging Trace Severity = 10 // Debug indicates that the log may be useful for debugging purposes Debug Severity = 20 // Info indicates that the log may be useful for understanding high level details about an application Info Severity = 30 // Notice indicates that the log should be noticed Notice Severity = 40 // Warning indicates that someone should look into an issue Warning Severity = 50 // Error indicates that something undesirable has actually happened Error Severity = 60 // Critical indicates that a problem requires attention immediately Critical Severity = 70 // Alert indicates that action must be taken immediately Alert Severity = 80 // Emergency indicates that the application is unusable Emergency Severity = 90 // Catastrophe indicates that it is already too late Catastrophe Severity = 100 // Nil is used to signal that severity is unknown or ambiguous Nil Severity = -1 )