factory: add SetLogger API

So that we actually use the same logger as other packages when being
invoked by CLI.

Fixes: #520

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao
2018-07-26 18:17:34 +08:00
parent b244410443
commit 9a497fedf5
3 changed files with 36 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import (
"syscall"
vc "github.com/kata-containers/runtime/virtcontainers"
vf "github.com/kata-containers/runtime/virtcontainers/factory"
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
@@ -146,6 +147,7 @@ func init() {
kataLog = logrus.WithFields(logrus.Fields{
"name": name,
"source": "runtime",
"arch": arch,
"pid": os.Getpid(),
})
@@ -194,6 +196,9 @@ func setExternalLoggers(logger *logrus.Entry) {
// Set virtcontainers logger.
vci.SetLogger(logger)
// Set vm factory logger.
vf.SetLogger(logger)
// Set the OCI package logger.
oci.SetLogger(logger)
}