logging: Add containerID and sandboxID to all log calls

Adding cid+sid fields to the log entries generated by most of the CLI
commands will make debugging across the system easier.

Fixes #452.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt
2018-06-28 10:07:07 +01:00
parent 93775487c8
commit a3ce12179f
10 changed files with 56 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"fmt"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@@ -55,6 +56,11 @@ func ps(containerID, format string, args []string) error {
containerID = status.ID
kataLog = kataLog.WithFields(logrus.Fields{
"container": containerID,
"sandbox": sandboxID,
})
// container MUST be running
if status.State.State != vc.StateRunning {
return fmt.Errorf("Container %s is not running", containerID)