Hide dots on daemon startup when loglevel != info
Phil Estes authored on 2015/03/19 23:10:18... | ... |
@@ -346,7 +346,7 @@ func (daemon *Daemon) restore() error { |
346 | 346 |
for _, v := range dir { |
347 | 347 |
id := v.Name() |
348 | 348 |
container, err := daemon.load(id) |
349 |
- if !debug { |
|
349 |
+ if !debug && log.GetLevel() == log.InfoLevel { |
|
350 | 350 |
fmt.Print(".") |
351 | 351 |
} |
352 | 352 |
if err != nil { |
... | ... |
@@ -368,7 +368,7 @@ func (daemon *Daemon) restore() error { |
368 | 368 |
|
369 | 369 |
if entities := daemon.containerGraph.List("/", -1); entities != nil { |
370 | 370 |
for _, p := range entities.Paths() { |
371 |
- if !debug { |
|
371 |
+ if !debug && log.GetLevel() == log.InfoLevel { |
|
372 | 372 |
fmt.Print(".") |
373 | 373 |
} |
374 | 374 |
|
... | ... |
@@ -420,7 +420,9 @@ func (daemon *Daemon) restore() error { |
420 | 420 |
} |
421 | 421 |
|
422 | 422 |
if !debug { |
423 |
- fmt.Println() |
|
423 |
+ if log.GetLevel() == log.InfoLevel { |
|
424 |
+ fmt.Println() |
|
425 |
+ } |
|
424 | 426 |
log.Infof("Loading containers: done.") |
425 | 427 |
} |
426 | 428 |
|
... | ... |
@@ -753,3 +753,50 @@ func TestDaemonLoggingDriverNoneLogsError(t *testing.T) { |
753 | 753 |
} |
754 | 754 |
logDone("daemon - logs not available for non-json-file drivers") |
755 | 755 |
} |
756 |
+ |
|
757 |
+func TestDaemonDots(t *testing.T) { |
|
758 |
+ defer deleteAllContainers() |
|
759 |
+ d := NewDaemon(t) |
|
760 |
+ if err := d.StartWithBusybox(); err != nil { |
|
761 |
+ t.Fatal(err) |
|
762 |
+ } |
|
763 |
+ |
|
764 |
+ // Now create 4 containers |
|
765 |
+ if _, err := d.Cmd("create", "busybox"); err != nil { |
|
766 |
+ t.Fatalf("Error creating container: %q", err) |
|
767 |
+ } |
|
768 |
+ if _, err := d.Cmd("create", "busybox"); err != nil { |
|
769 |
+ t.Fatalf("Error creating container: %q", err) |
|
770 |
+ } |
|
771 |
+ if _, err := d.Cmd("create", "busybox"); err != nil { |
|
772 |
+ t.Fatalf("Error creating container: %q", err) |
|
773 |
+ } |
|
774 |
+ if _, err := d.Cmd("create", "busybox"); err != nil { |
|
775 |
+ t.Fatalf("Error creating container: %q", err) |
|
776 |
+ } |
|
777 |
+ |
|
778 |
+ d.Stop() |
|
779 |
+ |
|
780 |
+ d.Start("--log-level=debug") |
|
781 |
+ d.Stop() |
|
782 |
+ content, _ := ioutil.ReadFile(d.logFile.Name()) |
|
783 |
+ if strings.Contains(string(content), "....") { |
|
784 |
+ t.Fatalf("Debug level should not have ....\n%s", string(content)) |
|
785 |
+ } |
|
786 |
+ |
|
787 |
+ d.Start("--log-level=error") |
|
788 |
+ d.Stop() |
|
789 |
+ content, _ = ioutil.ReadFile(d.logFile.Name()) |
|
790 |
+ if strings.Contains(string(content), "....") { |
|
791 |
+ t.Fatalf("Error level should not have ....\n%s", string(content)) |
|
792 |
+ } |
|
793 |
+ |
|
794 |
+ d.Start("--log-level=info") |
|
795 |
+ d.Stop() |
|
796 |
+ content, _ = ioutil.ReadFile(d.logFile.Name()) |
|
797 |
+ if !strings.Contains(string(content), "....") { |
|
798 |
+ t.Fatalf("Info level should have ....\n%s", string(content)) |
|
799 |
+ } |
|
800 |
+ |
|
801 |
+ logDone("daemon - test dots on INFO") |
|
802 |
+} |