parser

package
v0.0.0-...-b56178d Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotString = errors.New("no string in log body")
	ErrNotJson   = errors.New("no json object in log body")
)

Functions

func IsValidParser

func IsValidParser(parserType string) bool

Types

type JsonParser

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

func NewJsonParser

func NewJsonParser(config JsonParserConfig) (*JsonParser, error)

func (*JsonParser) Parse

func (p *JsonParser) Parse(log *types.Log) error

Attempts to parse the message as JSON and adds the parsed fields to the log body. Not safe for concurrent use.

type JsonParserConfig

type JsonParserConfig struct {
}

type Parser

type Parser interface {
	Parse(*types.Log) error
}

Parser is the interface for parsing log messages.

func NewParsers

func NewParsers(parserTypes []string, source string) []Parser

NewParsers creates a list of valid parser instances. Invalid parsers or those that cannot be created will be skipped with warning logs including the source string.

type ParserConfig

type ParserConfig struct {
	Type ParserType
}

ParserConfig is a structure used in configs for creating parsers instances.

type ParserType

type ParserType string
const ParserTypeJson ParserType = "json"

Jump to

Keyboard shortcuts

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