parse

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

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayLines

func DisplayLines(extraction []Extraction)

func DisplayTestLines

func DisplayTestLines(extraction []Extraction)

Types

type Config

type Config struct {
	Tokens       []string              `json:"tokens"`
	Patterns     []string              `json:"patterns"`
	Dependencies map[string][]string   `json:"dependencies,omitempty"`
	Conversions  map[string]Conversion `json:"conversions,omitempty"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

type Conversion

type Conversion struct {
	Token      string  `json:"token"`
	Multiplier float64 `json:"multiplier"`
}

type Extraction

type Extraction struct {
	Params     map[string]Param `json:"params"`
	Pattern    string           `json:"pattern"`
	LineNumber int              `json:"lineNumber"`
	Line       string           `json:"line"`
}

func Parse

func Parse(logtext string, config *Config) ([]Extraction, error)

Parse separates the log text into lines and attempts to extract tokens parameters from each line using the most appropriate pattern in the given config.

func ParseFast

func ParseFast(logtext string, config *Config) ([]Extraction, error)

ParseFast is identical to Parse but run concurrently.

func ParseFile

func ParseFile(path string, config *Config) ([]Extraction, error)

ParseFile reads the log text from the given file path, separates the text into lines and attempts to extract tokens parameters from each line using the most appropriate pattern in the given config.

func ParseFileTest

func ParseFileTest(path string, config *Config) ([]Extraction, error)

ParseTest runs ParseFile and displays a random sample of extracted parameters along with the origin lines from the log file.

func ParseFiles

func ParseFiles(paths []string, config *Config) ([]Extraction, error)

ParseFile reads the log text from each of the given file paths, separates the text into lines and attempts to extract tokens parameters from each line using the most appropriate pattern in the given config.

func ParseFilesTest

func ParseFilesTest(paths []string, config *Config) ([]Extraction, error)

ParseTest runs ParseFiles and displays a random sample of extracted parameters along with the origin lines from the log files.

func ParseLines

func ParseLines(lines []string, config *Config) ([]Extraction, error)

ParseLines attempts to extract tokens parameters from each line using the most appropriate pattern in the given config.

func ParseLinesFast

func ParseLinesFast(lines []string, config *Config) ([]Extraction, error)

ParseLinesFast is identical to ParseLines but run concurrently.

func ParseTest

func ParseTest(logtext string, config *Config) []Extraction

ParseTest runs Parse and displays a random sample of extracted parameters along with the origin lines from the log text.

type ExtractionDebug

type ExtractionDebug struct {
	Line       string         `json:"line"`
	LineNumber int            `json:"lineNumber"`
	Pattern    string         `json:"pattern"`
	Params     map[string]any `json:"params"`
}

type Param

type Param struct {
	Value any    `json:"value"`
	Type  string `json:"type"`
}

type PatternRank

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

Jump to

Keyboard shortcuts

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