github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/cli/debug/debug.go (about) 1 package debug 2 3 import ( 4 "os" 5 6 "github.com/sirupsen/logrus" 7 ) 8 9 // Enable sets the DEBUG env var to true 10 // and makes the logger to log at debug level. 11 func Enable() { 12 os.Setenv("DEBUG", "1") 13 logrus.SetLevel(logrus.DebugLevel) 14 } 15 16 // Disable sets the DEBUG env var to false 17 // and makes the logger to log at info level. 18 func Disable() { 19 os.Setenv("DEBUG", "") 20 logrus.SetLevel(logrus.InfoLevel) 21 } 22 23 // IsEnabled checks whether the debug flag is set or not. 24 func IsEnabled() bool { 25 return os.Getenv("DEBUG") != "" 26 }