Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
func Merge(ctx context.Context, in <-chan logsource.Result[*logsource.LogLine], detector *Detector) <-chan MergeResult
Merge reads physical lines from in and merges continuation lines into logical entries using the provided detector to identify entry boundaries. It propagates read errors from the ingestor Result channel. If no line is ever detected as a new entry (i.e. no recognizable timestamp), each physical line is emitted as its own entry to avoid behavioral regression.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector determines whether a log line is the start of a new log entry.
func NewDetector ¶
func NewDetector(cfg DetectorConfig) (*Detector, error)
NewDetector creates a new multiline entry boundary detector.
func (*Detector) IsNewEntry ¶
IsNewEntry returns true if the given line looks like the start of a new log entry (i.e. it begins with a timestamp or matches the firstline regex).
func (*Detector) MaxEntryBytes ¶
MaxEntryBytes returns the configured maximum entry size.
type DetectorConfig ¶
type DetectorConfig struct {
// MaxScanBytes is the maximum number of bytes to scan for timestamp
// detection at the beginning of each line. Default: 60.
MaxScanBytes int
// Threshold is the minimum probability for a line to be considered
// a new log entry. Default: 0.5.
Threshold float64
// FirstLineRegex is an optional regex pattern that overrides timestamp
// detection. If set, lines matching this regex are treated as new entries.
FirstLineRegex string
// MaxEntryBytes is the maximum size of a merged log entry in bytes.
// Entries exceeding this are flushed regardless of detection.
// Default: 65536 (64KB).
MaxEntryBytes int
}
DetectorConfig configures the multiline entry boundary detector.
type MergeResult ¶
type MergeResult struct {
Value *MergedLine
Err error
}
MergeResult wraps either a successfully merged line or an error from the input stream.
type MergedLine ¶
MergedLine represents one logical log entry that may span multiple physical lines.
func MergeSlice ¶
func MergeSlice(ctx context.Context, lines []string, detector *Detector) []MergedLine
MergeSlice merges a slice of log lines into logical entries. This is useful for non-streaming paths (analyze, debug commands). If no line is ever detected as a new entry, each line passes through individually.