From 456d2864a609a94be0e22442015dddc6fc3b6842 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 7 Feb 2023 21:17:36 +0100 Subject: [PATCH] Log config in JSON if possible Signed-off-by: Evan Lezar --- internal/runtime/runtime.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index 31a1187c..5634e75a 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -17,6 +17,7 @@ package runtime import ( + "encoding/json" "fmt" "strings" @@ -62,7 +63,14 @@ func (r rt) Run(argv []string) (rerr error) { r.logger.Reset() }() - r.logger.Infof("Using config %+v", cfg) + // Print the config to the output. + configJSON, err := json.MarshalIndent(cfg, "", " ") + if err == nil { + r.logger.Infof("Running with config:\n%v", string(configJSON)) + } else { + r.logger.Infof("Running with config:\n%+v", cfg) + } + r.logger.Debugf("Command line arguments: %v", argv) runtime, err := newNVIDIAContainerRuntime(r.logger.Logger, cfg, argv) if err != nil {