#254-handling-with-wrong-log-format

This commit is contained in:
Frol Kryuchkov 2021-06-11 17:22:34 +03:00
parent 29f9abf35c
commit 99be3b979e
1 changed files with 8 additions and 2 deletions

View File

@ -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]}
}
}
}()