Merge pull request #267 from frol-kr/bugfix/issue-254-crushes-when-container-logs-opened

#254-handling-with-wrong-log-format
This commit is contained in:
bradley 2021-06-11 13:46:42 -04:00 committed by GitHub
commit 2b898fb216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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]}
}
}
}()