Merge pull request #2661 from ktock/bklog

Do not drop logger set by containerd
master
Tõnis Tiigi 2022-02-23 08:05:22 -08:00 committed by GitHub
commit 9bc409d26b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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{})

View File

@ -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
}