From 04457e3830d2d4671a633a54f595bd071926ae5d Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Wed, 4 Jul 2018 13:43:18 +0100 Subject: [PATCH] logging: Add sandbox field Read the sandbox ID from the `agent.sandbox=` kernel command-line option and add a `sandbox=` log field with this value. This makes the logs more useful as every agent entry is now tied to a sandboxID. Fixes #291. Signed-off-by: James O. D. Hunt --- config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.go b/config.go index c5e842d6f7..c1f4a873cc 100644 --- a/config.go +++ b/config.go @@ -19,6 +19,7 @@ const ( optionPrefix = "agent." logLevelFlag = optionPrefix + "log" devModeFlag = optionPrefix + "devmode" + sandboxFlag = optionPrefix + "sandbox" kernelCmdlineFile = "/proc/cmdline" ) @@ -94,6 +95,8 @@ func (c *agentConfig) parseCmdlineOption(option string) error { if level == logrus.DebugLevel { debug = true } + case sandboxFlag: + agentLog = agentLog.WithField("sandbox", split[valuePosition]) default: if strings.HasPrefix(split[optionPosition], optionPrefix) { return grpcStatus.Errorf(codes.NotFound, "Unknown option %s", split[optionPosition])