mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Create log directory if required
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
61af2aee8e
commit
02656b624d
@ -156,11 +156,16 @@ func (l *Logger) Reset() error {
|
||||
}
|
||||
|
||||
func createLogFile(filename string) (*os.File, error) {
|
||||
if filename != "" && filename != os.DevNull {
|
||||
return os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if filename == "" || filename == os.DevNull {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
if dir := filepath.Dir(filepath.Clean(filename)); dir != "." {
|
||||
err := os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
}
|
||||
|
||||
type loggerConfig struct {
|
||||
|
Loading…
Reference in New Issue
Block a user