Skip to content

Commit

Permalink
logs: k8s-file: fix spurious error logs
Browse files Browse the repository at this point in the history
Fix the suprious "Error: nil" messages.  Also add some more context to
logged error messages which makes error sources more obvious.

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jun 21, 2021
1 parent ab4d0cf commit b7c44e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libpod/container_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption
}
nll, err := logs.NewLogLine(line.Text)
if err != nil {
logrus.Error(err)
logrus.Errorf("Error getting new log line: %v", err)
continue
}
if nll.Partial() {
Expand All @@ -100,10 +100,10 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption
// read the file until EOF.
tailError := t.StopAtEOF()
if tailError != nil && fmt.Sprintf("%v", tailError) != "tail: stop at eof" {
logrus.Error(tailError)
logrus.Errorf("Error stopping logger: %v", tailError)
}
if errors.Cause(err) != define.ErrNoSuchCtr {
logrus.Error(err)
if err != nil && errors.Cause(err) != define.ErrNoSuchCtr {
logrus.Errorf("Error getting container state: %v", err)
}
return nil
}
Expand All @@ -126,7 +126,7 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption
<-eventChannel
tailError := t.StopAtEOF()
if tailError != nil && fmt.Sprintf("%v", tailError) != "tail: stop at eof" {
logrus.Error(tailError)
logrus.Errorf("Error stopping logger: %v", tailError)
}
}()
}
Expand Down

0 comments on commit b7c44e2

Please sign in to comment.