debug.go 547 B

1234567891011121314151617181920212223242526
  1. package utils
  2. import (
  3. "os"
  4. "github.com/Sirupsen/logrus"
  5. )
  6. // EnableDebug sets the DEBUG env var to true
  7. // and makes the logger to log at debug level.
  8. func EnableDebug() {
  9. os.Setenv("DEBUG", "1")
  10. logrus.SetLevel(logrus.DebugLevel)
  11. }
  12. // DisableDebug sets the DEBUG env var to false
  13. // and makes the logger to log at info level.
  14. func DisableDebug() {
  15. os.Setenv("DEBUG", "")
  16. logrus.SetLevel(logrus.InfoLevel)
  17. }
  18. // IsDebugEnabled checks whether the debug flag is set or not.
  19. func IsDebugEnabled() bool {
  20. return os.Getenv("DEBUG") != ""
  21. }