log

package
v0.0.0-...-9f7285a Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedLogFieldExtractor

type CachedLogFieldExtractor struct {
	// contains filtered or unexported fields
}

CachedLogFieldExtractor implements CommonLogFieldExtractor and call the parent CommonLogFieldExtractor only when it was needed because accessing log fields from the Reader interface is a heavy operation.

func NewCachedLogFieldExtractor

func NewCachedLogFieldExtractor(parent CommonLogFieldExtractor) *CachedLogFieldExtractor

func (*CachedLogFieldExtractor) DisplayID

func (c *CachedLogFieldExtractor) DisplayID(l *LogEntity) string

DisplayID implements CommonLogFieldExtractor.

func (*CachedLogFieldExtractor) ID

ID implements CommonLogFieldExtractor.

func (*CachedLogFieldExtractor) LogBody

func (c *CachedLogFieldExtractor) LogBody(l *LogEntity) string

LogBody implements CommonLogFieldExtractor.

func (*CachedLogFieldExtractor) MainMessage

func (c *CachedLogFieldExtractor) MainMessage(l *LogEntity) (string, error)

MainMessage implements CommonLogFieldExtractor.

func (*CachedLogFieldExtractor) SetLogBodyCacheDirect

func (c *CachedLogFieldExtractor) SetLogBodyCacheDirect(logBody string)

SetLogBodyCacheDirect set the given logBody as the cache of LogBody.

func (*CachedLogFieldExtractor) Severity

Severity implements CommonLogFieldExtractor.

func (*CachedLogFieldExtractor) Timestamp

func (c *CachedLogFieldExtractor) Timestamp(l *LogEntity) time.Time

Timestamp implements CommonLogFieldExtractor.

type CommonLogFieldExtractor

type CommonLogFieldExtractor interface {
	// Get unique ID from a log. Unique but shorter id is preferable.
	ID(l *LogEntity) string
	// Get the timestamp from a log. This is used for sorting.
	Timestamp(l *LogEntity) time.Time
	// Extract the main content of the structured logging.
	// textPayload or jsonPayload.MESSAGE in GCP
	MainMessage(l *LogEntity) (string, error)
	// Severity of this log.
	Severity(l *LogEntity) (enum.Severity, error)
	// ID visible to user. This value isn't necessary to be unique.
	DisplayID(l *LogEntity) string
	// Entire log body represented as a string.
	LogBody(l *LogEntity) string
}

CommonLogFieldExtractor extracts information being available for all log entries(e.g timestamp)..etc These fields can be used outside of parsers specific to log types.

type LogEntity

type LogEntity struct {
	LogType enum.LogType

	Fields structure.Reader
	// contains filtered or unexported fields
}

LogEntity corresponds to a log record. Log itself is just a structured data and the main functionality is provided from structure.Reader. LogEntity adds few methods to get the common fields in logs like timestamp,id, severity ...etc.

func NewLogEntity

func NewLogEntity(reader *structure.Reader, commonFieldExtractor CommonLogFieldExtractor) *LogEntity

func (*LogEntity) DisplayId

func (l *LogEntity) DisplayId() string

func (*LogEntity) GetChildYamlOf

func (l *LogEntity) GetChildYamlOf(path string) (string, error)

func (*LogEntity) GetInt

func (l *LogEntity) GetInt(path string) (int, error)

func (*LogEntity) GetIntOrDefault

func (l *LogEntity) GetIntOrDefault(path string, def int) int

func (*LogEntity) GetString

func (l *LogEntity) GetString(path string) (string, error)

func (*LogEntity) GetStringOrDefault

func (l *LogEntity) GetStringOrDefault(path string, def string) string

func (*LogEntity) Has

func (l *LogEntity) Has(path string) bool

func (*LogEntity) HasKLogField

func (l *LogEntity) HasKLogField(klogField string) bool

func (*LogEntity) ID

func (l *LogEntity) ID() string

func (*LogEntity) KLogField

func (l *LogEntity) KLogField(klogField string) (string, error)

func (*LogEntity) LogBody

func (l *LogEntity) LogBody() string

func (*LogEntity) MainMessage

func (l *LogEntity) MainMessage() (string, error)

func (*LogEntity) Severity

func (l *LogEntity) Severity() (enum.Severity, error)

func (*LogEntity) Timestamp

func (l *LogEntity) Timestamp() time.Time

type UnreachableCommonFieldExtractor

type UnreachableCommonFieldExtractor struct{}

Empty commmon log field extractor. Just for testing purpose.

func (UnreachableCommonFieldExtractor) DisplayID

DisplayID implements CommonLogFieldExtractor.

func (UnreachableCommonFieldExtractor) ID

func (*UnreachableCommonFieldExtractor) LogBody

LogBody implements CommonLogFieldExtractor.

func (UnreachableCommonFieldExtractor) MainMessage

func (UnreachableCommonFieldExtractor) Severity

func (UnreachableCommonFieldExtractor) Timestamp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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