Skip to content

Commit

Permalink
bcicen#254-handling-with-wrong-log-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Frol Kryuchkov committed Jun 11, 2021
1 parent 29f9abf commit 99be3b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions connector/collector/docker_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ func (l *DockerLogs) Stream() chan models.Log {
scanner := bufio.NewScanner(r)
for scanner.Scan() {
parts := strings.SplitN(scanner.Text(), " ", 2)
ts := l.parseTime(parts[0])
logCh <- models.Log{Timestamp: ts, Message: parts[1]}
if len(parts) == 0 {
continue
}
if len(parts) < 2 {
logCh <- models.Log{Timestamp: l.parseTime(""), Message: parts[0]}
} else {
logCh <- models.Log{Timestamp: l.parseTime(parts[0]), Message: parts[1]}
}
}
}()

Expand Down

0 comments on commit 99be3b9

Please sign in to comment.