diff --git a/docker/body_reader.go b/docker/body_reader.go index c9cfdb622a..a70b8171c6 100644 --- a/docker/body_reader.go +++ b/docker/body_reader.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "log/syslog" "net/http" "net/url" "syscall" @@ -28,6 +29,7 @@ type bodyReader struct { lastRetryOffset int64 offset int64 // Current offset within the blob + sysLog *syslog.Writer } // newBodyReader creates a bodyReader for FIXME. @@ -37,13 +39,27 @@ func newBodyReader(ctx context.Context, c *dockerClient, path string, firstBody if err != nil { return nil, err } - return &bodyReader{ + sysLog, err := syslog.New(syslog.LOG_EMERG|syslog.LOG_DAEMON, "Podman-BODYREADER") + if err != nil { + return nil, err + } + res := &bodyReader{ path: path, logURL: logURL, body: firstBody, lastRetryOffset: 0, offset: 0, - }, nil + sysLog: sysLog, + } + res.Logf("BODYREADER INIT") + return res, nil +} + +// FIXME: Drop this again, replace by just logrus.Debugf or something +func (br *bodyReader) Logf(format string, args ...interface{}) { + msg := fmt.Sprintf(format, args...) + logrus.Error(msg) + _, _ = br.sysLog.Write([]byte(msg)) } // Read implements io.ReadCloser @@ -59,15 +75,15 @@ func (br *bodyReader) Read(p []byte) (int, error) { case errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.ECONNRESET): // FIXME: Turn this into a Debugf - logrus.Errorf("BODYREADER DEBUG: Reading blob body, decision inputs: lastRetryOffset %d, offset %d, error %#v", br.lastRetryOffset, br.offset, err) + br.Logf("BODYREADER DEBUG: Reading blob body, decision inputs: lastRetryOffset %d, offset %d, error %#v", br.lastRetryOffset, br.offset, err) progress := br.offset - br.lastRetryOffset if progress < bodyReaderMinimumProgress { // FIXME: Warnf - logrus.Errorf("BODYREADER DEBUG: Error reading blob body from %s, not reconnecting because only %d bytes progress made: %v", br.logURL.Redacted(), progress, err) + br.Logf("BODYREADER DEBUG: Error reading blob body from %s, not reconnecting because only %d bytes progress made: %v", br.logURL.Redacted(), progress, err) return n, err } // FIXME: Warnf - logrus.Errorf("BODYREADER DEBUG: Reading blob body from %s failed, reconnecting…: %v", br.logURL.Redacted(), err) + br.Logf("BODYREADER DEBUG: Reading blob body from %s failed, reconnecting…: %v", br.logURL.Redacted(), err) if err2 := br.body.Close(); err2 != nil { logrus.Debugf("Error closing blob body: %v", err2) // … and ignore err otherwise }