entry

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 6 Imported by: 23

Documentation

Index

Constants

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 Entry

type Entry struct {
	Timestamp    time.Time         `json:"timestamp"               yaml:"timestamp"`
	Severity     Severity          `json:"severity"                yaml:"severity"`
	SeverityText string            `json:"severity_text,omitempty" yaml:"severity_text,omitempty"`
	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) AddLabel

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

AddLabel will add a key/value pair to the entry's labels.

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 NewLabelField

func NewLabelField(key string) Field

NewLabelField will creat a new label field from a key

func NewNilField

func NewNilField() Field

NewNilField will create a new nil field

func NewRecordField

func NewRecordField(keys ...string) Field

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

func NewResourceField added in v0.9.13

func NewResourceField(key 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 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.

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 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

	// Trace2 indicates that the log may be useful for detailed debugging
	Trace2 Severity = 12

	// Trace3 indicates that the log may be useful for detailed debugging
	Trace3 Severity = 13

	// Trace4 indicates that the log may be useful for detailed debugging
	Trace4 Severity = 14

	// Debug indicates that the log may be useful for debugging purposes
	Debug Severity = 20

	// Debug2 indicates that the log may be useful for debugging purposes
	Debug2 Severity = 22

	// Debug3 indicates that the log may be useful for debugging purposes
	Debug3 Severity = 23

	// Debug4 indicates that the log may be useful for debugging purposes
	Debug4 Severity = 24

	// Info indicates that the log may be useful for understanding high level details about an application
	Info Severity = 30

	// Info2 indicates that the log may be useful for understanding high level details about an application
	Info2 Severity = 32

	// Info3 indicates that the log may be useful for understanding high level details about an application
	Info3 Severity = 33

	// Info4 indicates that the log may be useful for understanding high level details about an application
	Info4 Severity = 34

	// Notice indicates that the log should be noticed
	Notice Severity = 40

	// Warning indicates that someone should look into an issue
	Warning Severity = 50

	// Warning2 indicates that someone should look into an issue
	Warning2 Severity = 52

	// Warning3 indicates that someone should look into an issue
	Warning3 Severity = 53

	// Warning4 indicates that someone should look into an issue
	Warning4 Severity = 54

	// Error indicates that something undesirable has actually happened
	Error Severity = 60

	// Error2 indicates that something undesirable has actually happened
	Error2 Severity = 62

	// Error3 indicates that something undesirable has actually happened
	Error3 Severity = 63

	// Error4 indicates that something undesirable has actually happened
	Error4 Severity = 64

	// 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

	// Emergency2 indicates that the application is unusable
	Emergency2 Severity = 92

	// Emergency3 indicates that the application is unusable
	Emergency3 Severity = 93

	// Emergency4 indicates that the application is unusable
	Emergency4 Severity = 94

	// Catastrophe indicates that it is already too late
	Catastrophe Severity = 100
)

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