From 48fbd60e335248edb43bc3e900dc0684090e0a1f Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Mon, 30 Oct 2017 15:58:13 +0000 Subject: [PATCH] helper: Fall back to TF_LOG_PATH instead of os.Stderr --- helper/resource/testing.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helper/resource/testing.go b/helper/resource/testing.go index 9766ff57a..dce4e416e 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -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