mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Define a basic logger interface
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -16,13 +16,13 @@
|
||||
|
||||
package system
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
import "github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
||||
|
||||
// Option is a functional option for the system command
|
||||
type Option func(*Interface)
|
||||
|
||||
// WithLogger sets the logger for the system command
|
||||
func WithLogger(logger *logrus.Logger) Option {
|
||||
func WithLogger(logger logger.Interface) Option {
|
||||
return func(i *Interface) {
|
||||
i.logger = logger
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/info/proc/devices"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Interface is the interface for the system command
|
||||
type Interface struct {
|
||||
logger *logrus.Logger
|
||||
logger logger.Interface
|
||||
dryRun bool
|
||||
loadKernelModules bool
|
||||
nvidiaDevices nvidiaDevices
|
||||
@@ -39,7 +39,7 @@ type Interface struct {
|
||||
// New constructs a system command with the specified options
|
||||
func New(opts ...Option) (*Interface, error) {
|
||||
i := &Interface{
|
||||
logger: logrus.StandardLogger(),
|
||||
logger: logger.New(),
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(i)
|
||||
|
||||
Reference in New Issue
Block a user