func IsDebugOrHigher() bool {
	level := string(CurrentLogLevel())
	return level == "DEBUG" || level == "TRACE"
}
IsDebugOrHigher returns whether or not the current log level is debug or trace
package logging
import (
	"io"
	"io/ioutil"
	"log"
	"os"
	"strings"
	"syscall"
)
const (
	EnvLog     = "TF_LOG"       
	EnvLogFile = "TF_LOG_PATH"  
)
var ValidLevels = []LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"}
func LogOutput() (logOutput io.Writer, err error) {
	logOutput = ioutil.Discard
	logLevel := CurrentLogLevel()
	if logLevel == "" {
		return
	}
	logOutput = os.Stderr
	if logPath := os.Getenv(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 logLevel == "TRACE" {
		return logOutput, nil
	}
	logOutput = &LevelFilter{
		Levels:   ValidLevels,
		MinLevel: LogLevel(logLevel),
		Writer:   logOutput,
	}
	return logOutput, nil
}
func SetOutput() {
	out, err := LogOutput()
	if err != nil {
		log.Fatal(err)
	}
	if out == nil {
		out = ioutil.Discard
	}
	log.SetOutput(out)
}
func CurrentLogLevel() string {
	envLevel := os.Getenv(EnvLog)
	if envLevel == "" {
		return ""
	}
	logLevel := "TRACE"
	if isValidLogLevel(envLevel) {
		logLevel = strings.ToUpper(envLevel)
	} else {
		log.Printf("[WARN] Invalid log level: %q. Defaulting to level: TRACE. Valid levels are: %+v",
			envLevel, ValidLevels)
	}
	if logLevel != "TRACE" {
		log.Printf("[WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.\n  Use TF_LOG=TRACE to see Terraform's internal logs.\n  ----")
	}
	return logLevel
}