Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit 54f87f5

Browse files
author
James O. D. Hunt
committed
logging: Add CLI command to logs
Since the runtime is called multiple times by the container manager, add the command-line sub-command name to all log entries to make it clear which command was running when a particular log message was produced. Note that CLI arguments are already logged once at runtime startup. This change is more useful for the scenarios where only a log excerpt is available (for example when running `cc-collect-data.sh` which only extracts error logs). Fixes #1024. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
1 parent 81d8b6f commit 54f87f5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ func beforeSubcommands(context *cli.Context) error {
202202

203203
ignoreLogging := false
204204

205+
// Add the name of the sub-command to each log entry for easier
206+
// debugging.
207+
name := context.Args().First()
208+
if context.App.Command(name) != nil {
209+
ccLog = ccLog.WithField("command", name)
210+
}
211+
205212
if context.NArg() == 1 && context.Args()[0] == envCmd {
206213
// simply report the logging setup
207214
ignoreLogging = true

0 commit comments

Comments
 (0)