Call logger.Reset() to ensure errors are captured

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2022-05-12 15:42:42 +02:00
parent 19138a2110
commit 60dacb76b6
2 changed files with 3 additions and 2 deletions

View File

@ -118,9 +118,9 @@ func UpdateLogger(filename string, logLevel string, argv []string) (*Logger, err
return l, nil 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. // was before UpdateLogger was called.
func (l *Logger) CloseFile() error { func (l *Logger) Reset() error {
defer func() { defer func() {
previous := l.previousLogger previous := l.previousLogger
if previous == nil { if previous == nil {

View File

@ -35,6 +35,7 @@ func run(argv []string) (rerr error) {
if err != nil { if err != nil {
return fmt.Errorf("failed to set up logger: %v", err) return fmt.Errorf("failed to set up logger: %v", err)
} }
defer logger.Reset()
logger.Debugf("Command line arguments: %v", argv) logger.Debugf("Command line arguments: %v", argv)
runtime, err := newNVIDIAContainerRuntime(logger.Logger, cfg, argv) runtime, err := newNVIDIAContainerRuntime(logger.Logger, cfg, argv)