diff --git a/cmd/buildkitd/main.go b/cmd/buildkitd/main.go index abf8fa05..126ba0db 100644 --- a/cmd/buildkitd/main.go +++ b/cmd/buildkitd/main.go @@ -15,7 +15,6 @@ import ( "strings" "time" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/pkg/seed" "github.com/containerd/containerd/pkg/userns" "github.com/containerd/containerd/platforms" @@ -76,9 +75,6 @@ func init() { if reexec.Init() { os.Exit(0) } - - // overwrites containerd/log.G - log.G = bklog.GetLogger } var propagators = propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}) diff --git a/util/bklog/log.go b/util/bklog/log.go index 99e6c995..d7f20221 100644 --- a/util/bklog/log.go +++ b/util/bklog/log.go @@ -3,10 +3,17 @@ package bklog import ( "context" + "github.com/containerd/containerd/log" "github.com/sirupsen/logrus" "go.opentelemetry.io/otel/trace" ) +func init() { + // overwrites containerd/log + log.G = GetLogger + log.L = L +} + var ( G = GetLogger L = logrus.NewEntry(logrus.StandardLogger()) @@ -37,6 +44,8 @@ func GetLogger(ctx context.Context) (l *logrus.Entry) { if logger != nil { l = logger.(*logrus.Entry) + } else if logger := log.GetLogger(ctx); logger != nil { + l = logger } else { l = L }