From acdd0b8e688a9f91e1772d8a1e6216cfd8d69349 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 26 Jul 2018 14:08:08 +0100 Subject: [PATCH] logging: Split logging source into two fields Don't use slash-delimited values in log fields - create two separate log fields (`source` and `subsystem`) for clarity. Signed-off-by: James O. D. Hunt --- virtcontainers/pkg/hyperstart/hyperstart.go | 5 ++++- virtcontainers/pkg/oci/utils.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/virtcontainers/pkg/hyperstart/hyperstart.go b/virtcontainers/pkg/hyperstart/hyperstart.go index 36474566ef..44548bd4c6 100644 --- a/virtcontainers/pkg/hyperstart/hyperstart.go +++ b/virtcontainers/pkg/hyperstart/hyperstart.go @@ -124,7 +124,10 @@ var hyperLog = logrus.FieldLogger(logrus.New()) // SetLogger sets the logger for hyperstart package. func SetLogger(logger logrus.FieldLogger) { - hyperLog = logger.WithField("source", "virtcontainers/hyperstart") + hyperLog = logger.WithFields(logrus.Fields{ + "source": "virtcontainers", + "subsystem": "hyperstart", + }) } // NewHyperstart returns a new hyperstart structure. diff --git a/virtcontainers/pkg/oci/utils.go b/virtcontainers/pkg/oci/utils.go index 680354b1d7..0fb67ad5d4 100644 --- a/virtcontainers/pkg/oci/utils.go +++ b/virtcontainers/pkg/oci/utils.go @@ -132,7 +132,10 @@ var ociLog = logrus.FieldLogger(logrus.New()) // SetLogger sets the logger for oci package. func SetLogger(logger logrus.FieldLogger) { - ociLog = logger.WithField("source", "virtcontainers/oci") + ociLog = logger.WithFields(logrus.Fields{ + "source": "virtcontainers", + "subsystem": "oci", + }) } func cmdEnvs(spec CompatOCISpec, envs []vc.EnvVar) []vc.EnvVar {