Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions internal/pkg/source/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ type LazyLogEntry struct {
length int
}

// Length of the entry.
func (e LazyLogEntry) Length() int {
return e.length
}

// Line re-reads the line.
func (e LazyLogEntry) Line(file *os.File) (json.RawMessage, error) {
data := make([]byte, e.length)

_, err := file.ReadAt(data, e.offset)
if err != nil {
return nil, err
Expand All @@ -45,7 +48,7 @@ func (e LazyLogEntry) LogEntry(file *os.File, cfg *config.Config) LogEntry {
}
}

return ParseLogEntry(line, cfg)
return parseLogEntry(line, cfg)
}

// LogEntry is a single partly-parse record of the log.
Expand Down Expand Up @@ -90,6 +93,7 @@ func (entries LazyLogEntries) Filter(term string) (LazyLogEntries, error) {
if err != nil {
return LazyLogEntries{}, err
}

if bytes.Contains(bytes.ToLower(line), termLower) {
filtered = append(filtered, f)
}
Expand Down Expand Up @@ -151,8 +155,6 @@ func formatField(
return string(ParseLevel(formatMessage(value), cfg.CustomLevelMapping))
case config.FieldKindTime:
return formatMessage(value)
case config.FieldKindNumericTime:
return formatMessage(value)
case config.FieldKindSecondTime:
return formatMessage(formatTimeString(value, "s"))
case config.FieldKindMilliTime:
Expand All @@ -166,8 +168,8 @@ func formatField(
}
}

// ParseLogEntry parses a single log entry from the json line.
func ParseLogEntry(
// parseLogEntry parses a single log entry from the json line.
func parseLogEntry(
line json.RawMessage,
cfg *config.Config,
) LogEntry {
Expand Down
Loading
Loading