Remove most logrus

Signed-off-by: Jin Dong <jin.dong@databricks.com>
This commit is contained in:
Jin Dong
2023-08-26 13:17:03 -04:00
parent 03e4f1e363
commit fc45365fa1
31 changed files with 84 additions and 94 deletions

View File

@@ -24,7 +24,6 @@ import (
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/log"
"github.com/sirupsen/logrus"
"github.com/containerd/containerd/pkg/cri/util"
cioutil "github.com/containerd/containerd/pkg/ioutil"
@@ -161,7 +160,7 @@ func (c *ContainerIO) Attach(opts AttachOptions) {
c.stdin.Close()
// Also closes the containerd side.
if err := opts.CloseStdin(); err != nil {
logrus.WithError(err).Errorf("Failed to close stdin for container %q", c.id)
log.L.WithError(err).Errorf("Failed to close stdin for container %q", c.id)
}
} else {
if opts.Stdout != nil {
@@ -177,7 +176,7 @@ func (c *ContainerIO) Attach(opts AttachOptions) {
attachStream := func(key string, close <-chan struct{}) {
<-close
logrus.Infof("Attach stream %q closed", key)
log.L.Infof("Attach stream %q closed", key)
// Make sure stdin gets closed.
if stdinStreamRC != nil {
stdinStreamRC.Close()

View File

@@ -23,9 +23,9 @@ import (
"io"
"time"
"github.com/sirupsen/logrus"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/containerd/log"
cioutil "github.com/containerd/containerd/pkg/ioutil"
)
@@ -51,7 +51,7 @@ func NewDiscardLogger() io.WriteCloser {
// maxLen is the max length limit of a line. A line longer than the
// limit will be cut into multiple lines.
func NewCRILogger(path string, w io.Writer, stream StreamType, maxLen int) (io.WriteCloser, <-chan struct{}) {
logrus.Debugf("Start writing stream %q to log file %q", stream, path)
log.L.Debugf("Start writing stream %q to log file %q", stream, path)
prc, pwc := io.Pipe()
stop := make(chan struct{})
go func() {
@@ -147,7 +147,7 @@ func redirectLogs(path string, rc io.ReadCloser, w io.Writer, s StreamType, maxL
outputEntries.Inc()
outputBytes.Inc(float64(n))
} else {
logrus.WithError(err).Errorf("Fail to write %q log to log file %q", s, path)
log.L.WithError(err).Errorf("Fail to write %q log to log file %q", s, path)
// Continue on write error to drain the container output.
}
}
@@ -167,9 +167,9 @@ func redirectLogs(path string, rc io.ReadCloser, w io.Writer, s StreamType, maxL
}
if err != nil {
if err == io.EOF {
logrus.Debugf("Getting EOF from stream %q while redirecting to log file %q", s, path)
log.L.Debugf("Getting EOF from stream %q while redirecting to log file %q", s, path)
} else {
logrus.WithError(err).Errorf("An error occurred when redirecting stream %q to log file %q", s, path)
log.L.WithError(err).Errorf("An error occurred when redirecting stream %q to log file %q", s, path)
}
if length == 0 {
// No content left to write, break.
@@ -209,5 +209,5 @@ func redirectLogs(path string, rc io.ReadCloser, w io.Writer, s StreamType, maxL
break
}
}
logrus.Debugf("Finish redirecting stream %q to log file %q", s, path)
log.L.Debugf("Finish redirecting stream %q to log file %q", s, path)
}