debug.go 545 B

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