helper: Fall back to TF_LOG_PATH instead of os.Stderr

This commit is contained in:
Radek Simko 2017-10-30 15:58:13 +00:00
parent 574d348f79
commit 48fbd60e33
No known key found for this signature in database
GPG Key ID: 1F1C84FE689A88D7
1 changed files with 9 additions and 0 deletions

View File

@ -372,6 +372,15 @@ func LogOutput(t TestT) (logOutput io.Writer, err error) {
}
logOutput = os.Stderr
if logPath := os.Getenv(logging.EnvLogFile); logPath != "" {
var err error
logOutput, err = os.OpenFile(logPath, syscall.O_CREAT|syscall.O_RDWR|syscall.O_APPEND, 0666)
if err != nil {
return nil, err
}
}
if logPathMask := os.Getenv(EnvLogPathMask); logPathMask != "" {
logPath := fmt.Sprintf(logPathMask, t.Name())
var err error