log

package
v0.55.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldSet

func GetFieldSet[T FieldSet](l *Log, fieldSet T) (T, error)

GetFieldSet returns the read FieldSet associated with the log. It returns an error when the FieldSet wasn't found on the log.

func MustGetFieldSet

func MustGetFieldSet[T FieldSet](l *Log, fieldSet T) T

MustGetFieldSet returns the read FieldSet associated with the log. It will go panic when the FieldSet was not found on the log.

Types

type CommonFieldSet

type CommonFieldSet struct {
	// Timestamp is the timestamp of the log happens.
	Timestamp time.Time
	// Severity represents the log severity.
	Severity enum.Severity
	// DisplayID is an unique identifier given from a log.
	// This is only used for showing and it may be same as the ID.
	DisplayID string
}

CommonFieldSet is an abstract FieldSet struct type to get fields commonly defined in logs.

func (*CommonFieldSet) Kind

func (c *CommonFieldSet) Kind() string

Kind implements FieldSet.

type FieldSet

type FieldSet interface {
	// FieldSetKind identifies the set of fields. It must be same if the result type has same fields.
	Kind() string
}

FieldSet represents set of log fields read from a log. FieldSet implementations defines how to read these actual fields from a log for parsers to read without using explicit path of field.

type FieldSetReader

type FieldSetReader interface {
	// Read attempts to read the log fields into its field.
	Read(reader *structured.NodeReader) (FieldSet, error)

	// FieldSetKind identifies the set of fields. It must be same if the result type has same fields.
	FieldSetKind() string
}

type Log

type Log struct {
	*structured.NodeReader

	ID      string
	LogType enum.LogType
	// contains filtered or unexported fields
}

Log represents a log handled in KHI. It provides direct access to its fields and abstracted cached access via FieldSet interface.

func NewLog

func NewLog(reader *structured.NodeReader) *Log

NewLog returns a log instance from NodeReader instance.

func NewLogFromYAMLString

func NewLogFromYAMLString(yaml string) (*Log, error)

NewLogFromYAMLString instanciate a new Log from the given YAML string.

func NewLogWithFieldSetsForTest

func NewLogWithFieldSetsForTest(fieldSets ...FieldSet) *Log

NewLogWithFieldSetsForTest generate an empty Log with given FieldSet. This is for testing purpose to instanciate a log already parsed.

func (*Log) SetFieldSetReader

func (l *Log) SetFieldSetReader(reader FieldSetReader) error

SetFieldSetReader reads set of fields with the FieldSetReader and keep it in the log.

type MainMessageFieldSet

type MainMessageFieldSet struct {
	MainMessage string
}

MainMessageFieldSet is an abstract FieldSet struct type to get the main message of its log. This would be read from `textPayload`, `protoPayload` or `jsonPayload` when it is read from Cloud Logging.

func (*MainMessageFieldSet) Kind

func (d *MainMessageFieldSet) Kind() string

Kind implements FieldSet.

Jump to

Keyboard shortcuts

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