Documentation
¶
Index ¶
- func DisplayLines(extraction []Extraction)
- func DisplayTestLines(extraction []Extraction)
- func Export(w io.Writer, format string, extractions []Extraction) error
- func FormatFromPath(path string) string
- func FprintExtraction(w io.Writer, e Extraction)
- func ParseStream(r io.Reader, config *Config, follow bool, emit func(Extraction) error) error
- func ValidateConfig(config Config) error
- func WriteConfigTest(extractions []Extraction) (path string, err error)
- type Config
- type Conversion
- type Extraction
- func Parse(logtext string, config *Config) ([]Extraction, error)
- func ParseFile(path string, config *Config) ([]Extraction, error)
- func ParseFileTest(path string, config *Config) ([]Extraction, error)
- func ParseFiles(paths []string, config *Config) ([]Extraction, error)
- func ParseFilesTest(paths []string, config *Config) ([]Extraction, error)
- func ParseLines(lines []string, config *Config) ([]Extraction, error)
- func ParseReader(r io.Reader, config *Config) ([]Extraction, error)
- type Param
- type PatternRank
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayLines ¶
func DisplayLines(extraction []Extraction)
func DisplayTestLines ¶
func DisplayTestLines(extraction []Extraction)
func Export ¶
func Export(w io.Writer, format string, extractions []Extraction) error
Export writes the extracted records to w in the given format. Supported formats are "json" (a pretty-printed array), "ndjson" (one JSON object per line) and "csv" (a table with one column per token).
func FormatFromPath ¶
FormatFromPath infers an export format from a file extension, returning an empty string when the extension is unrecognised.
func FprintExtraction ¶
func FprintExtraction(w io.Writer, e Extraction)
FprintExtraction writes a single extraction in the human-readable form used by the print output. It is used when streaming records one at a time.
func ParseStream ¶
ParseStream reads lines from r one at a time and calls emit with the extraction for each non-blank line as soon as the line is available. Only single-line patterns are considered, since streaming cannot look ahead for multi-line patterns.
When follow is true, reaching the end of the input means "wait for more data" rather than "done", so a growing file can be tailed; the call then returns only on error or an emit failure. When follow is false it returns at EOF, which also lets it stream naturally from a pipe (each line is emitted as soon as it is written, and the pipe closing ends the stream).
func ValidateConfig ¶
ValidateConfig checks configuration references before parsing begins, so typos produce useful startup errors rather than silent missing dashboard data.
func WriteConfigTest ¶
func WriteConfigTest(extractions []Extraction) (path string, err error)
WriteConfigTest writes extractions to a new JSON file in the current directory and returns its path. CreateTemp prevents collisions between runs and creates the file with owner-only permissions.
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 ¶
type Conversion ¶
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 ParseFile ¶
func ParseFile(path string, config *Config) ([]Extraction, error)
ParseFile streams the log text from the given file path and attempts to extract token parameters from each line using the most appropriate pattern in the given config.
func ParseFileTest ¶
func ParseFileTest(path string, config *Config) ([]Extraction, error)
ParseFileTest parses one log file for config-test mode.
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)
ParseFilesTest parses all log files for config-test mode.
func ParseLines ¶
func ParseLines(lines []string, config *Config) ([]Extraction, error)
ParseLines attempts to extract token parameters from each line using the most appropriate pattern in the given config. When the config contains no multi-line patterns the lines are parsed concurrently; otherwise a sequential pass is used so lines consumed by a multi-line match are skipped correctly. Both paths produce identical, in-order results.
func ParseReader ¶
func ParseReader(r io.Reader, config *Config) ([]Extraction, error)
ParseReader streams log lines from r and extracts token parameters from each line using the most appropriate pattern in the given config. Reading from a stream avoids holding a second full-size copy of the log in memory, so it scales to large files and also supports stdin.
type PatternRank ¶
type PatternRank struct {
// contains filtered or unexported fields
}