2016-12-12 03:33:58 -05:00
|
|
|
package debug
|
2015-12-10 18:35:10 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2016-12-12 03:33:58 -05:00
|
|
|
// Enable sets the DEBUG env var to true
|
2015-12-10 18:35:10 -05:00
|
|
|
// and makes the logger to log at debug level.
|
2016-12-12 03:33:58 -05:00
|
|
|
func Enable() {
|
2015-12-10 18:35:10 -05:00
|
|
|
os.Setenv("DEBUG", "1")
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
|
2016-12-12 03:33:58 -05:00
|
|
|
// Disable sets the DEBUG env var to false
|
2015-12-10 18:35:10 -05:00
|
|
|
// and makes the logger to log at info level.
|
2016-12-12 03:33:58 -05:00
|
|
|
func Disable() {
|
2015-12-10 18:35:10 -05:00
|
|
|
os.Setenv("DEBUG", "")
|
|
|
|
logrus.SetLevel(logrus.InfoLevel)
|
|
|
|
}
|
|
|
|
|
2016-12-12 03:33:58 -05:00
|
|
|
// IsEnabled checks whether the debug flag is set or not.
|
|
|
|
func IsEnabled() bool {
|
2015-12-10 18:35:10 -05:00
|
|
|
return os.Getenv("DEBUG") != ""
|
|
|
|
}
|