Skip to content

Commit 179ffb5

Browse files
committed
replace direct uses of logrus for containerd/log
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent bd1b1a1 commit 179ffb5

File tree

29 files changed

+103
-101
lines changed

29 files changed

+103
-101
lines changed

cli-plugins/manager/hooks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
"encoding/json"
66
"strings"
77

8+
"github.com/containerd/log"
89
"github.com/docker/cli/cli-plugins/hooks"
910
"github.com/docker/cli/cli/config"
1011
"github.com/docker/cli/cli/config/configfile"
11-
"github.com/sirupsen/logrus"
1212
"github.com/spf13/cobra"
1313
"github.com/spf13/pflag"
1414
)
@@ -106,7 +106,7 @@ func invokeAndCollectHooks(ctx context.Context, cfg *configfile.ConfigFile, root
106106
var appended bool
107107
nextSteps, appended = appendNextSteps(nextSteps, processedHook)
108108
if !appended {
109-
logrus.Debugf("Plugin %s responded with an empty hook message %q. Ignoring.", pluginName, string(hookReturn))
109+
log.G(ctx).Debugf("Plugin %s responded with an empty hook message %q. Ignoring.", pluginName, string(hookReturn))
110110
}
111111
}
112112
return nextSteps

cli-plugins/socket/socket.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"runtime"
1111
"sync"
1212

13-
"github.com/sirupsen/logrus"
13+
"github.com/containerd/log"
1414
)
1515

1616
// EnvKey represents the well-known environment variable used to pass the
@@ -32,7 +32,7 @@ func NewPluginServer(h func(net.Conn)) (*PluginServer, error) {
3232
if err != nil {
3333
return nil, err
3434
}
35-
logrus.Trace("Plugin server listening on ", l.Addr())
35+
log.L.Logger.Trace("Plugin server listening on ", l.Addr())
3636

3737
if h == nil {
3838
h = func(net.Conn) {}
@@ -98,7 +98,7 @@ func (pl *PluginServer) Close() error {
9898
if pl == nil {
9999
return nil
100100
}
101-
logrus.Trace("Closing plugin server")
101+
log.L.Logger.Trace("Closing plugin server")
102102
// Close connections first to ensure the connections get io.EOF instead
103103
// of a connection reset.
104104
pl.closeAllConns()

cli/command/container/attach.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"errors"
66
"io"
77

8+
"github.com/containerd/log"
89
"github.com/docker/cli/cli"
910
"github.com/docker/cli/cli/command"
1011
"github.com/docker/cli/cli/command/completion"
1112
"github.com/moby/moby/api/types/container"
1213
"github.com/moby/moby/client"
1314
"github.com/moby/sys/signal"
14-
"github.com/sirupsen/logrus"
1515
"github.com/spf13/cobra"
1616
)
1717

@@ -182,6 +182,6 @@ func resizeTTY(ctx context.Context, dockerCli command.Cli, containerID string) {
182182
// After the above resizing occurs, the call to MonitorTtySize below will handle resetting back
183183
// to the actual size.
184184
if err := MonitorTtySize(ctx, dockerCli, containerID, false); err != nil {
185-
logrus.Debugf("Error monitoring TTY size: %s", err)
185+
log.G(ctx).Debugf("Error monitoring TTY size: %s", err)
186186
}
187187
}

cli/command/container/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
"fmt"
77
"io"
88

9+
"github.com/containerd/log"
910
"github.com/docker/cli/cli"
1011
"github.com/docker/cli/cli/command"
1112
"github.com/docker/cli/cli/command/completion"
1213
"github.com/docker/cli/cli/config/configfile"
1314
"github.com/docker/cli/opts"
1415
"github.com/moby/moby/api/types/container"
1516
"github.com/moby/moby/client"
16-
"github.com/sirupsen/logrus"
1717
"github.com/spf13/cobra"
1818
)
1919

@@ -194,7 +194,7 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execOptions *cl
194194
}
195195

196196
if err := <-errCh; err != nil {
197-
logrus.Debugf("Error hijack: %s", err)
197+
log.G(ctx).Debugf("Error hijack: %s", err)
198198
return err
199199
}
200200

cli/command/container/hijack.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"runtime"
88
"sync"
99

10+
"github.com/containerd/log"
1011
"github.com/docker/cli/cli/command"
1112
"github.com/moby/moby/api/pkg/stdcopy"
1213
"github.com/moby/moby/client"
1314
"github.com/moby/term"
14-
"github.com/sirupsen/logrus"
1515
)
1616

1717
// The default escape key sequence: ctrl-p, ctrl-q
@@ -105,7 +105,7 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) {
105105
if h.detachKeys != "" {
106106
customEscapeKeys, err := term.ToBytes(h.detachKeys)
107107
if err != nil {
108-
logrus.Warnf("invalid detach escape keys, using default: %s", err)
108+
log.G(context.TODO()).Warnf("invalid detach escape keys, using default: %s", err)
109109
} else {
110110
escapeKeys = customEscapeKeys
111111
}
@@ -140,10 +140,10 @@ func (h *hijackedIOStreamer) beginOutputStream(restoreInput func()) <-chan error
140140
_, err = stdcopy.StdCopy(h.outputStream, h.errorStream, h.resp.Reader)
141141
}
142142

143-
logrus.Debug("[hijack] End of stdout")
143+
log.G(context.TODO()).Debug("[hijack] End of stdout")
144144

145145
if err != nil {
146-
logrus.Debugf("Error receiveStdout: %s", err)
146+
log.G(context.TODO()).Debugf("Error receiveStdout: %s", err)
147147
}
148148

149149
outputDone <- err
@@ -164,7 +164,7 @@ func (h *hijackedIOStreamer) beginInputStream(restoreInput func()) (doneC <-chan
164164
// messages will be in normal type.
165165
restoreInput()
166166

167-
logrus.Debug("[hijack] End of stdin")
167+
log.G(context.TODO()).Debug("[hijack] End of stdin")
168168

169169
if _, ok := err.(term.EscapeError); ok {
170170
detached <- err
@@ -175,12 +175,12 @@ func (h *hijackedIOStreamer) beginInputStream(restoreInput func()) (doneC <-chan
175175
// This error will also occur on the receive
176176
// side (from stdout) where it will be
177177
// propagated back to the caller.
178-
logrus.Debugf("Error sendStdin: %s", err)
178+
log.G(context.TODO()).Debugf("Error sendStdin: %s", err)
179179
}
180180
}
181181

182182
if err := h.resp.CloseWrite(); err != nil {
183-
logrus.Debugf("Couldn't send EOF: %s", err)
183+
log.G(context.TODO()).Debugf("Couldn't send EOF: %s", err)
184184
}
185185

186186
close(inputDone)

cli/command/container/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"syscall"
1111

12+
"github.com/containerd/log"
1213
"github.com/docker/cli/cli"
1314
"github.com/docker/cli/cli/command"
1415
"github.com/docker/cli/cli/command/completion"
@@ -17,7 +18,6 @@ import (
1718
"github.com/moby/moby/client"
1819
"github.com/moby/sys/signal"
1920
"github.com/moby/term"
20-
"github.com/sirupsen/logrus"
2121
"github.com/spf13/cobra"
2222
"github.com/spf13/pflag"
2323
)
@@ -237,7 +237,7 @@ func runContainer(ctx context.Context, dockerCli command.Cli, runOpts *runOption
237237
return nil
238238
}
239239

240-
logrus.Debugf("Error hijack: %s", err)
240+
log.G(ctx).Debugf("Error hijack: %s", err)
241241
return err
242242
}
243243
status := <-statusChan

cli/command/container/signals.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"os"
66
gosignal "os/signal"
77

8+
"github.com/containerd/log"
89
"github.com/moby/moby/client"
910
"github.com/moby/sys/signal"
10-
"github.com/sirupsen/logrus"
1111
)
1212

1313
// ForwardAllSignals forwards signals to the container
@@ -52,7 +52,7 @@ func ForwardAllSignals(ctx context.Context, apiClient client.ContainerAPIClient,
5252
Signal: sig,
5353
})
5454
if err != nil {
55-
logrus.Debugf("Error sending signal: %s", err)
55+
log.G(ctx).Debugf("Error sending signal: %s", err)
5656
}
5757
}
5858
}

cli/command/container/tty.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
"runtime"
99
"time"
1010

11+
"github.com/containerd/log"
1112
"github.com/docker/cli/cli/command"
1213
"github.com/moby/moby/client"
1314
"github.com/moby/sys/signal"
14-
"github.com/sirupsen/logrus"
1515
)
1616

1717
// TODO(thaJeztah): split resizeTTYTo
@@ -40,7 +40,7 @@ func resizeTTYTo(ctx context.Context, apiClient resizeClient, id string, height,
4040
}
4141

4242
if err != nil {
43-
logrus.Debugf("Error resize: %s\r", err)
43+
log.G(ctx).Debugf("Error resize: %s\r", err)
4444
}
4545
return err
4646
}

cli/command/container/utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"context"
55
"errors"
66

7+
"github.com/containerd/log"
78
"github.com/moby/moby/api/types/container"
89
"github.com/moby/moby/client"
9-
"github.com/sirupsen/logrus"
1010
)
1111

1212
func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containerID string, waitRemove bool) <-chan int {
@@ -32,7 +32,7 @@ func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containe
3232
return
3333
case result := <-waitRes.Result:
3434
if result.Error != nil {
35-
logrus.Errorf("Error waiting for container: %v", result.Error.Message)
35+
log.G(ctx).Errorf("Error waiting for container: %v", result.Error.Message)
3636
statusC <- 125
3737
} else {
3838
statusC <- int(result.StatusCode)
@@ -41,7 +41,7 @@ func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containe
4141
if errors.Is(err, context.Canceled) {
4242
return
4343
}
44-
logrus.Errorf("error waiting for container: %v", err)
44+
log.G(ctx).Errorf("error waiting for container: %v", err)
4545
statusC <- 125
4646
}
4747
}()

cli/command/inspect/inspector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ package inspect
55

66
import (
77
"bytes"
8+
"context"
89
"encoding/json"
910
"errors"
1011
"fmt"
1112
"io"
1213
"text/template"
1314

15+
"github.com/containerd/log"
1416
"github.com/docker/cli/cli"
1517
"github.com/docker/cli/templates"
16-
"github.com/sirupsen/logrus"
1718
)
1819

1920
// Inspector defines an interface to implement to process elements
@@ -93,7 +94,7 @@ func Inspect(out io.Writer, references []string, tmplStr string, getRef GetRefFu
9394
}
9495

9596
if err := inspector.Flush(); err != nil {
96-
logrus.Error(err)
97+
log.G(context.TODO()).Error(err)
9798
}
9899

99100
if err := errors.Join(errs...); err != nil {

0 commit comments

Comments
 (0)