From 60dacb76b6b49a51876be0ab6fbea22a40d49492 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 12 May 2022 15:42:42 +0200 Subject: [PATCH] Call logger.Reset() to ensure errors are captured Signed-off-by: Evan Lezar --- cmd/nvidia-container-runtime/logger.go | 4 ++-- cmd/nvidia-container-runtime/main.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/nvidia-container-runtime/logger.go b/cmd/nvidia-container-runtime/logger.go index 56ebad6c..e886a020 100644 --- a/cmd/nvidia-container-runtime/logger.go +++ b/cmd/nvidia-container-runtime/logger.go @@ -118,9 +118,9 @@ func UpdateLogger(filename string, logLevel string, argv []string) (*Logger, err return l, nil } -// CloseFile closes the log file (if any) and resets the logger output to what it +// Reset closes the log file (if any) and resets the logger output to what it // was before UpdateLogger was called. -func (l *Logger) CloseFile() error { +func (l *Logger) Reset() error { defer func() { previous := l.previousLogger if previous == nil { diff --git a/cmd/nvidia-container-runtime/main.go b/cmd/nvidia-container-runtime/main.go index ba5b3514..4b8651fb 100644 --- a/cmd/nvidia-container-runtime/main.go +++ b/cmd/nvidia-container-runtime/main.go @@ -35,6 +35,7 @@ func run(argv []string) (rerr error) { if err != nil { return fmt.Errorf("failed to set up logger: %v", err) } + defer logger.Reset() logger.Debugf("Command line arguments: %v", argv) runtime, err := newNVIDIAContainerRuntime(logger.Logger, cfg, argv)