Skip to content

Commit

Permalink
compatoci: Add a SetLogger call
Browse files Browse the repository at this point in the history
Add a standard `SetLogger()` call to allow the `compatoci` package to be
provided a base logger which it can then customise.

Fixes: kata-containers#2305.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Dec 2, 2019
1 parent 0a5315b commit 67f203f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
deviceApi "github.com/kata-containers/runtime/virtcontainers/device/api"
deviceConfig "github.com/kata-containers/runtime/virtcontainers/device/config"
"github.com/kata-containers/runtime/virtcontainers/persist/fs"
"github.com/kata-containers/runtime/virtcontainers/pkg/compatoci"
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
"github.com/kata-containers/runtime/virtcontainers/store"
"github.com/kata-containers/runtime/virtcontainers/types"
Expand Down Expand Up @@ -50,6 +51,7 @@ func SetLogger(ctx context.Context, logger *logrus.Entry) {

deviceApi.SetLogger(virtLog)
store.SetLogger(virtLog)
compatoci.SetLogger(virtLog)
}

// CreateSandbox is the virtcontainers sandbox creation entry point.
Expand Down
7 changes: 7 additions & 0 deletions virtcontainers/pkg/compatoci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ func containerCapabilities(s compatOCISpec) (specs.LinuxCapabilities, error) {
return c, nil
}

// SetLogger sets up a logger for this pkg
func SetLogger(logger *logrus.Entry) {
fields := ociLog.Data

ociLog = logger.WithFields(fields)
}

// ContainerCapabilities return a LinuxCapabilities for virtcontainer
func ContainerCapabilities(s compatOCISpec) (specs.LinuxCapabilities, error) {
if s.Process == nil {
Expand Down

0 comments on commit 67f203f

Please sign in to comment.