Browse code

Merge pull request #11965 from duglin/DEBUG

Remove use of "DEBUG" env var from CLI and de-couple -D from --log-level

Jessie Frazelle authored on 2015/05/13 10:24:04
Showing 3 changed files
... ...
@@ -3,7 +3,6 @@ package client
3 3
 import (
4 4
 	"encoding/json"
5 5
 	"fmt"
6
-	"os"
7 6
 
8 7
 	"github.com/docker/docker/api/types"
9 8
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -45,9 +44,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
45 45
 	fmt.Fprintf(cli.out, "Name: %s\n", info.Name)
46 46
 	fmt.Fprintf(cli.out, "ID: %s\n", info.ID)
47 47
 
48
-	if info.Debug || os.Getenv("DEBUG") != "" {
48
+	if info.Debug {
49 49
 		fmt.Fprintf(cli.out, "Debug mode (server): %v\n", info.Debug)
50
-		fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
51 50
 		fmt.Fprintf(cli.out, "File Descriptors: %d\n", info.NFd)
52 51
 		fmt.Fprintf(cli.out, "Goroutines: %d\n", info.NGoroutines)
53 52
 		fmt.Fprintf(cli.out, "System Time: %s\n", info.SystemTime)
... ...
@@ -53,11 +53,8 @@ func main() {
53 53
 		setLogLevel(logrus.InfoLevel)
54 54
 	}
55 55
 
56
-	// -D, --debug, -l/--log-level=debug processing
57
-	// When/if -D is removed this block can be deleted
58 56
 	if *flDebug {
59 57
 		os.Setenv("DEBUG", "1")
60
-		setLogLevel(logrus.DebugLevel)
61 58
 	}
62 59
 
63 60
 	if len(flHosts) == 0 {
... ...
@@ -232,8 +232,8 @@ func (s *DockerDaemonSuite) TestDaemonFlagD(c *check.C) {
232 232
 		c.Fatal(err)
233 233
 	}
234 234
 	content, _ := ioutil.ReadFile(s.d.logFile.Name())
235
-	if !strings.Contains(string(content), `level=debug`) {
236
-		c.Fatalf(`Missing level="debug" in log file using -D:\n%s`, string(content))
235
+	if strings.Contains(string(content), `level=debug`) {
236
+		c.Fatalf(`Should not have level="debug" in log file using -D:\n%s`, string(content))
237 237
 	}
238 238
 }
239 239
 
... ...
@@ -242,8 +242,8 @@ func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *check.C) {
242 242
 		c.Fatal(err)
243 243
 	}
244 244
 	content, _ := ioutil.ReadFile(s.d.logFile.Name())
245
-	if !strings.Contains(string(content), `level=debug`) {
246
-		c.Fatalf(`Missing level="debug" in log file using --debug:\n%s`, string(content))
245
+	if strings.Contains(string(content), `level=debug`) {
246
+		c.Fatalf(`Should not have level="debug" in log file using --debug:\n%s`, string(content))
247 247
 	}
248 248
 }
249 249
 
... ...
@@ -252,8 +252,8 @@ func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *check.C) {
252 252
 		c.Fatal(err)
253 253
 	}
254 254
 	content, _ := ioutil.ReadFile(s.d.logFile.Name())
255
-	if !strings.Contains(string(content), `level=debug`) {
256
-		c.Fatalf(`Missing level="debug" in log file when using both --debug and --log-level=fatal:\n%s`, string(content))
255
+	if strings.Contains(string(content), `level=debug`) {
256
+		c.Fatalf(`Should not have level="debug" in log file when using both --debug and --log-level=fatal:\n%s`, string(content))
257 257
 	}
258 258
 }
259 259