2018-02-05 16:05:59 -05:00
|
|
|
package debug // import "github.com/docker/docker/cli/debug"
|
2015-12-10 18:35:10 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2017-07-26 17:42:13 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2015-12-10 18:35:10 -05:00
|
|
|
)
|
|
|
|
|
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") != ""
|
|
|
|
}
|