mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
NRI: use the daemon's logger
Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
29
daemon/internal/nri/logshim.go
Normal file
29
daemon/internal/nri/logshim.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package nri
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/containerd/log"
|
||||
nrilog "github.com/containerd/nri/pkg/log"
|
||||
)
|
||||
|
||||
type logShim struct{}
|
||||
|
||||
// logShim implements interface nrilog.Logger.
|
||||
var _ nrilog.Logger = (*logShim)(nil)
|
||||
|
||||
func (nls *logShim) Debugf(ctx context.Context, format string, args ...any) {
|
||||
log.G(ctx).Debugf("NRI: "+format, args...)
|
||||
}
|
||||
|
||||
func (nls *logShim) Infof(ctx context.Context, format string, args ...any) {
|
||||
log.G(ctx).Infof("NRI: "+format, args...)
|
||||
}
|
||||
|
||||
func (nls *logShim) Warnf(ctx context.Context, format string, args ...any) {
|
||||
log.G(ctx).Warnf("NRI: "+format, args...)
|
||||
}
|
||||
|
||||
func (nls *logShim) Errorf(ctx context.Context, format string, args ...any) {
|
||||
log.G(ctx).Errorf("NRI: "+format, args...)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/containerd/log"
|
||||
"github.com/containerd/nri/pkg/adaptation"
|
||||
nrilog "github.com/containerd/nri/pkg/log"
|
||||
"github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/internal/rootless"
|
||||
"github.com/moby/moby/v2/daemon/pkg/opts"
|
||||
@@ -57,6 +58,7 @@ func NewNRI(ctx context.Context, cfg Config) (*NRI, error) {
|
||||
"pluginConfigPath": n.cfg.DaemonConfig.PluginConfigPath,
|
||||
"socketPath": n.cfg.DaemonConfig.SocketPath,
|
||||
}).Info("Starting NRI")
|
||||
nrilog.Set(&logShim{})
|
||||
|
||||
var err error
|
||||
n.nri, err = adaptation.New("docker", dockerversion.Version, n.syncFn, n.updateFn, nriOptions(n.cfg.DaemonConfig)...)
|
||||
|
||||
Reference in New Issue
Block a user