github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/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" 11 const EnvLogFile = "TF_LOG_PATH" 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 }