Browse code

Use an environment variable to activate debug mode, instead of a package-specific flag

Solomon Hykes authored on 2013/04/03 02:58:16
Showing 2 changed files
... ...
@@ -21,7 +21,9 @@ func main() {
21 21
 	flDaemon := flag.Bool("d", false, "Daemon mode")
22 22
 	flDebug := flag.Bool("D", false, "Debug mode")
23 23
 	flag.Parse()
24
-	rcli.DEBUG_FLAG = *flDebug
24
+	if *flDebug {
25
+		os.Setenv("DEBUG", "1")
26
+	}
25 27
 	if *flDaemon {
26 28
 		if flag.NArg() != 0 {
27 29
 			flag.Usage()
... ...
@@ -45,7 +45,7 @@ func Download(url string, stderr io.Writer) (*http.Response, error) {
45 45
 // Debug function, if the debug flag is set, then display. Do nothing otherwise
46 46
 // If Docker is in damon mode, also send the debug info on the socket
47 47
 func Debugf(format string, a ...interface{}) {
48
-	if rcli.DEBUG_FLAG {
48
+	if os.Getenv("DEBUG") != "" {
49 49
 
50 50
 		// Retrieve the stack infos
51 51
 		_, file, line, ok := runtime.Caller(1)