main: Pass runtime CLI command to vc logger

Add the runtime CLI command name to the virtcontainers logger so that it
is clear when reading virtcontainers log entries which runtime command
they refer to.

Fixes #448.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2018-06-27 11:58:42 +01:00
parent 47dfb7d6da
commit 830d50e9c5

View File

@ -235,10 +235,6 @@ func beforeSubcommands(context *cli.Context) error {
return fmt.Errorf("unknown log-format %q", context.GlobalString("log-format"))
}
setExternalLoggers(kataLog)
ignoreLogging := false
// Add the name of the sub-command to each log entry for easier
// debugging.
cmdName := context.Args().First()
@ -246,6 +242,10 @@ func beforeSubcommands(context *cli.Context) error {
kataLog = kataLog.WithField("command", cmdName)
}
setExternalLoggers(kataLog)
ignoreLogging := false
if context.NArg() == 1 && context.Args()[0] == envCmd {
// simply report the logging setup
ignoreLogging = true