github.com/lamielle/terraform@v0.3.2-0.20141121070651-81f008ba53d5/log.go (about) 1 package main 2 3 import ( 4 "io" 5 "os" 6 ) 7 8 // These are the environmental variables that determine if we log, and if 9 // we log whether or not the log should go to a file. 10 const EnvLog = "TF_LOG" //Set to True 11 const EnvLogFile = "TF_LOG_PATH" //Set to a file 12 13 // logOutput determines where we should send logs (if anywhere). 14 func logOutput() (logOutput io.Writer, err error) { 15 logOutput = nil 16 if os.Getenv(EnvLog) != "" { 17 logOutput = os.Stderr 18 19 if logPath := os.Getenv(EnvLogFile); logPath != "" { 20 var err error 21 logOutput, err = os.Create(logPath) 22 if err != nil { 23 return nil, err 24 } 25 } 26 } 27 28 return 29 }