Skip to content

Commit

Permalink
Skipped malformed docker-compose log lines (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm authored Jun 8, 2023
1 parent a28f696 commit a58c8ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/stack/parselogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ package stack
import (
"bufio"
"encoding/json"
"fmt"
"os"
"strings"
"time"

"github.com/elastic/elastic-package/internal/logger"
)

type ParseLogsOptions struct {
Expand Down Expand Up @@ -41,7 +42,8 @@ func ParseLogs(options ParseLogsOptions, process func(log LogLine) error) error
messageSlice := strings.SplitN(line, "|", 2)

if len(messageSlice) != 2 {
return fmt.Errorf("malformed docker-compose log line")
logger.Debugf("skipped malformed docker-compose log line: %s", line)
continue
}

messageLog := messageSlice[1]
Expand All @@ -54,6 +56,8 @@ func ParseLogs(options ParseLogsOptions, process func(log LogLine) error) error
}

// There could be valid messages with just plain text without timestamp
// and therefore not processed, cannot be ensured in which timestamp they
// were generated
if !startProcessing && log.Timestamp.Before(options.StartTime) {
continue
}
Expand Down

0 comments on commit a58c8ba

Please sign in to comment.