Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFieldSet ¶
GetFieldSet returns the read FieldSet associated with the log. It returns an error when the FieldSet wasn't found on the log.
func MustGetFieldSet ¶
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.
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 ¶
NewLogFromYAMLString instanciate a new Log from the given YAML string.
func NewLogWithFieldSetsForTest ¶
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) HasKLogField ¶
func (m *MainMessageFieldSet) HasKLogField(fieldName string) bool
HasKLogField parses the main message as the klog format and returns if the field exists.
func (*MainMessageFieldSet) KLogField ¶
func (m *MainMessageFieldSet) KLogField(fieldName string) (string, error)
KLogField parses the main message as the klog format and returns the field value.
func (*MainMessageFieldSet) KLogSeverity ¶
func (m *MainMessageFieldSet) KLogSeverity() enum.Severity
KLogSeverity reads the severity field from KLog formatted message.
func (*MainMessageFieldSet) Kind ¶
func (d *MainMessageFieldSet) Kind() string
Kind implements FieldSet.