entry

package
v0.29.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 22

Documentation

Index

Constants

View Source
const (
	AttributesPrefix = "attributes"
	ResourcePrefix   = "resource"
	BodyPrefix       = "body"
)
View Source
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

func (f BodyField) Child(key string) BodyField

Child returns a child of the current field using the given key.

func (BodyField) Delete added in v0.17.0

func (f BodyField) Delete(entry *Entry) (interface{}, bool)

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

func (f BodyField) Get(entry *Entry) (interface{}, bool)

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

func (f BodyField) MarshalJSON() ([]byte, error)

MarshalJSON will marshal the field for JSON.

func (BodyField) MarshalYAML added in v0.17.0

func (f BodyField) MarshalYAML() (interface{}, error)

MarshalYAML will marshal the field for YAML.

func (BodyField) Merge added in v0.17.0

func (f BodyField) Merge(entry *Entry, mapValues map[string]interface{})

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

func (f BodyField) Parent() BodyField

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

func (f BodyField) Set(entry *Entry, value interface{}) error

Set will set a value on an entry's body using the field. If a key already exists, it will be overwritten.

func (BodyField) String added in v0.17.0

func (f BodyField) String() string

String returns the string representation of this field.

func (*BodyField) UnmarshalJSON added in v0.17.0

func (f *BodyField) UnmarshalJSON(raw []byte) error

UnmarshalJSON will attempt to unmarshal the field from JSON.

func (*BodyField) UnmarshalYAML added in v0.17.0

func (f *BodyField) UnmarshalYAML(unmarshal func(interface{}) error) error

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

func (entry *Entry) AddAttribute(key, value string)

AddAttribute will add a key/value pair to the entry's attributes.

func (*Entry) AddResourceKey

func (entry *Entry) AddResourceKey(key, value string)

AddResourceKey wil add a key/value pair to the entry's resource.

func (*Entry) Copy

func (entry *Entry) Copy() *Entry

Copy will return a deep copy of the entry.

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

func NewAttributeField(keys ...string) Field

NewAttributeField will creat a new attribute field from a key

func NewBodyField added in v0.17.0

func NewBodyField(keys ...string) Field

NewBodyField creates a new field from an ordered array of keys.

func NewField added in v0.18.0

func NewField(s string) (Field, error)

func NewNilField

func NewNilField() Field

NewNilField will create a new nil field

func NewResourceField

func NewResourceField(keys ...string) Field

NewResourceField will creat a new resource field from a key

func (Field) MarshalJSON

func (f Field) MarshalJSON() ([]byte, error)

MarshalJSON will marshal a field into JSON

func (Field) MarshalYAML

func (f Field) MarshalYAML() (interface{}, error)

MarshalYAML will marshal a field into YAML

func (*Field) UnmarshalJSON

func (f *Field) UnmarshalJSON(raw []byte) error

UnmarshalJSON will unmarshal a field from JSON

func (*Field) UnmarshalYAML

func (f *Field) UnmarshalYAML(unmarshal func(interface{}) error) error

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.

func (NilField) Delete

func (l NilField) Delete(entry *Entry) (interface{}, bool)

Delete will do nothing and return no error

func (NilField) Get

func (l NilField) Get(entry *Entry) (interface{}, bool)

Get will return always return nil

func (NilField) Set

func (l NilField) Set(entry *Entry, val interface{}) error

Set will do nothing and return no error

func (NilField) String

func (l NilField) String() string

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
)

func (Severity) String

func (s Severity) String() string

ToString converts a severity to a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL