output

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, records []parser.Record, ids []int, format Format) error

Write writes the matched records to w in the given format.

func WriteGroups added in v0.6.2

func WriteGroups(w io.Writer, groups []GroupResult, format Format) error

WriteGroups writes aggregation results to w in the given format.

func WritePatterns added in v1.0.0

func WritePatterns(w io.Writer, results []PatternResult, format Format) error

WritePatterns writes pattern clustering results to w in the given format.

func WriteWithColumns added in v0.6.2

func WriteWithColumns(w io.Writer, records []parser.Record, ids []int, format Format, columns []string) error

WriteWithColumns writes matched records using the given columns as header. If columns is nil, falls back to Write().

Types

type Format

type Format string

Format represents an output format.

const (
	FormatRaw  Format = "raw"
	FormatJSON Format = "json"
	FormatCSV  Format = "csv"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat parses a format string, returning an error for unknown formats.

type GroupResult added in v0.6.2

type GroupResult struct {
	Value string `json:"value"`
	Count int    `json:"count"`
}

GroupResult holds a field value and its count.

func GroupBy added in v0.6.2

func GroupBy(records []parser.Record, ids []int, field string) []GroupResult

GroupBy counts records per unique value of the given field. Results are sorted descending by count.

func TopN added in v0.6.2

func TopN(groups []GroupResult, n int) []GroupResult

TopN returns the first n results, or all if n <= 0.

type PatternResult added in v1.0.0

type PatternResult struct {
	Template string `json:"template"`
	Count    int    `json:"count"`
}

PatternResult holds a message template and its occurrence count.

Jump to

Keyboard shortcuts

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