func CurrentLogLevel() string {
	ll, _ := globalLogLevel()
	return strings.ToUpper(ll.String())
}
CurrentLogLevel returns the current log level string based the environment vars
package logging
import (
	"fmt"
	"io"
	"log"
	"os"
	"strings"
	"syscall"
	"github.com/hashicorp/go-hclog"
)
const (
	envLog     = "TF_LOG"
	envLogFile = "TF_LOG_PATH"
	envLogCore     = "TF_LOG_CORE"
	envLogProvider = "TF_LOG_PROVIDER"
)
var (
	ValidLevels = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"}
	logger hclog.Logger
	logWriter io.Writer
	panics = &panicRecorder{
		panics:   make(map[string][]string),
		maxLines: 100,
	}
)
func init() {
	logger = newHCLogger("")
	logWriter = logger.StandardWriter(&hclog.StandardLoggerOptions{InferLevels: true})
	log.SetFlags(0)
	log.SetPrefix("")
	log.SetOutput(logWriter)
}
func RegisterSink(f *os.File) {
	l, ok := logger.(hclog.InterceptLogger)
	if !ok {
		panic("global logger is not an InterceptLogger")
	}
	if f == nil {
		return
	}
	l.RegisterSink(hclog.NewSinkAdapter(&hclog.LoggerOptions{
		Level:  hclog.Trace,
		Output: f,
	}))
}
func LogOutput() io.Writer {
	return logWriter
}
func HCLogger() hclog.Logger {
	return logger
}
func newHCLogger(name string) hclog.Logger {
	logOutput := io.Writer(os.Stderr)
	logLevel, json := globalLogLevel()
	if logPath := os.Getenv(envLogFile); logPath != "" {
		f, err := os.OpenFile(logPath, syscall.O_CREAT|syscall.O_RDWR|syscall.O_APPEND, 0666)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error opening log file: %v\n", err)
		} else {
			logOutput = f
		}
	}
	return hclog.NewInterceptLogger(&hclog.LoggerOptions{
		Name:              name,
		Level:             logLevel,
		Output:            logOutput,
		IndependentLevels: true,
		JSONFormat:        json,
	})
}
func NewLogger(name string) hclog.Logger {
	if name == "" {
		panic("logger name required")
	}
	return &logPanicWrapper{
		Logger: logger.Named(name),
	}
}
func NewProviderLogger(prefix string) hclog.Logger {
	l := &logPanicWrapper{
		Logger: logger.Named(prefix + "provider"),
	}
	level := providerLogLevel()
	logger.Debug("created provider logger", "level", level)
	l.SetLevel(level)
	return l
}