X Tutup
Skip to content

Commit c9064df

Browse files
committed
Discard grpc logs by default
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
1 parent 709ba26 commit c9064df

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

linux/shim.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ package linux
55
import (
66
"context"
77
"fmt"
8-
"io/ioutil"
9-
"log"
108
"net"
119
"os/exec"
1210
"path/filepath"
1311
"syscall"
1412
"time"
1513

1614
"google.golang.org/grpc"
17-
"google.golang.org/grpc/grpclog"
1815

1916
"github.com/containerd/containerd/api/services/shim"
2017
localShim "github.com/containerd/containerd/linux/shim"
21-
containerdlog "github.com/containerd/containerd/log"
18+
"github.com/containerd/containerd/log"
2219
"github.com/containerd/containerd/reaper"
2320
"github.com/containerd/containerd/sys"
2421
"github.com/pkg/errors"
@@ -58,7 +55,7 @@ func newShim(ctx context.Context, shimName string, path, namespace string, remot
5855
cmd.Process.Kill()
5956
reaper.Default.Wait(cmd)
6057
} else {
61-
containerdlog.G(ctx).WithField("socket", socket).Infof("new shim started")
58+
log.G(ctx).WithField("socket", socket).Infof("new shim started")
6259
}
6360
}()
6461
if err = sys.SetOOMScore(cmd.Process.Pid, sys.OOMScoreMaxKillable); err != nil {
@@ -77,7 +74,6 @@ func loadShim(path, namespace string, remote bool) (shim.ShimClient, error) {
7774

7875
func connectShim(socket string) (shim.ShimClient, error) {
7976
// reset the logger for grpc to log to dev/null so that it does not mess with our stdio
80-
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
8177
dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithTimeout(100 * time.Second)}
8278
dialOpts = append(dialOpts,
8379
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {

log/grpc.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package log
22

33
import (
4-
"context"
4+
"io/ioutil"
5+
"log"
56

67
"google.golang.org/grpc/grpclog"
78
)
89

910
func init() {
10-
ctx := WithModule(context.Background(), "grpc")
11-
12-
// completely replace the grpc logger with the logrus logger.
13-
grpclog.SetLogger(G(ctx))
11+
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
1412
}

0 commit comments

Comments
 (0)
X Tutup