2018-02-05 21:05:59 +00:00
|
|
|
package debug // import "github.com/docker/docker/cli/debug"
|
2015-12-10 23:35:10 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2023-09-13 15:41:45 +00:00
|
|
|
"github.com/containerd/log"
|
2015-12-10 23:35:10 +00:00
|
|
|
)
|
|
|
|
|
2016-12-12 08:33:58 +00:00
|
|
|
// Enable sets the DEBUG env var to true
|
2015-12-10 23:35:10 +00:00
|
|
|
// and makes the logger to log at debug level.
|
2016-12-12 08:33:58 +00:00
|
|
|
func Enable() {
|
2015-12-10 23:35:10 +00:00
|
|
|
os.Setenv("DEBUG", "1")
|
2023-07-30 15:18:56 +00:00
|
|
|
_ = log.SetLevel("debug")
|
2015-12-10 23:35:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 08:33:58 +00:00
|
|
|
// Disable sets the DEBUG env var to false
|
2015-12-10 23:35:10 +00:00
|
|
|
// and makes the logger to log at info level.
|
2016-12-12 08:33:58 +00:00
|
|
|
func Disable() {
|
2015-12-10 23:35:10 +00:00
|
|
|
os.Setenv("DEBUG", "")
|
2023-07-30 15:18:56 +00:00
|
|
|
_ = log.SetLevel("info")
|
2015-12-10 23:35:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 08:33:58 +00:00
|
|
|
// IsEnabled checks whether the debug flag is set or not.
|
|
|
|
func IsEnabled() bool {
|
2015-12-10 23:35:10 +00:00
|
|
|
return os.Getenv("DEBUG") != ""
|
|
|
|
}
|