When the deamon starts up with log level set to INFO it will show something
like this:
```
INFO[0000] Loading containers: start.
................................................................
INFO[0000] Loading containers: done.
```
where the dots represent containers in the system.
When you run with log level set to "error" it will still show the dots
w/o the "Loading..." lines before and after which looks really odd.
This PR will fix it so that the dots are only shown IFF the "Loading..."
lines are also shown
Signed-off-by: Doug Davis <dug@us.ibm.com>
| ... | ... |
@@ -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 |
|
| ... | ... |
@@ -726,3 +726,50 @@ func TestDaemonLoggingDriverNoneLogsError(t *testing.T) {
|
| 726 | 726 |
} |
| 727 | 727 |
logDone("daemon - logs not available for non-json-file drivers")
|
| 728 | 728 |
} |
| 729 |
+ |
|
| 730 |
+func TestDaemonDots(t *testing.T) {
|
|
| 731 |
+ defer deleteAllContainers() |
|
| 732 |
+ d := NewDaemon(t) |
|
| 733 |
+ if err := d.StartWithBusybox(); err != nil {
|
|
| 734 |
+ t.Fatal(err) |
|
| 735 |
+ } |
|
| 736 |
+ |
|
| 737 |
+ // Now create 4 containers |
|
| 738 |
+ if _, err := d.Cmd("create", "busybox"); err != nil {
|
|
| 739 |
+ t.Fatalf("Error creating container: %q", err)
|
|
| 740 |
+ } |
|
| 741 |
+ if _, err := d.Cmd("create", "busybox"); err != nil {
|
|
| 742 |
+ t.Fatalf("Error creating container: %q", err)
|
|
| 743 |
+ } |
|
| 744 |
+ if _, err := d.Cmd("create", "busybox"); err != nil {
|
|
| 745 |
+ t.Fatalf("Error creating container: %q", err)
|
|
| 746 |
+ } |
|
| 747 |
+ if _, err := d.Cmd("create", "busybox"); err != nil {
|
|
| 748 |
+ t.Fatalf("Error creating container: %q", err)
|
|
| 749 |
+ } |
|
| 750 |
+ |
|
| 751 |
+ d.Stop() |
|
| 752 |
+ |
|
| 753 |
+ d.Start("--log-level=debug")
|
|
| 754 |
+ d.Stop() |
|
| 755 |
+ content, _ := ioutil.ReadFile(d.logFile.Name()) |
|
| 756 |
+ if strings.Contains(string(content), "....") {
|
|
| 757 |
+ t.Fatalf("Debug level should not have ....\n%s", string(content))
|
|
| 758 |
+ } |
|
| 759 |
+ |
|
| 760 |
+ d.Start("--log-level=error")
|
|
| 761 |
+ d.Stop() |
|
| 762 |
+ content, _ = ioutil.ReadFile(d.logFile.Name()) |
|
| 763 |
+ if strings.Contains(string(content), "....") {
|
|
| 764 |
+ t.Fatalf("Error level should not have ....\n%s", string(content))
|
|
| 765 |
+ } |
|
| 766 |
+ |
|
| 767 |
+ d.Start("--log-level=info")
|
|
| 768 |
+ d.Stop() |
|
| 769 |
+ content, _ = ioutil.ReadFile(d.logFile.Name()) |
|
| 770 |
+ if !strings.Contains(string(content), "....") {
|
|
| 771 |
+ t.Fatalf("Info level should have ....\n%s", string(content))
|
|
| 772 |
+ } |
|
| 773 |
+ |
|
| 774 |
+ logDone("daemon - test dots on INFO")
|
|
| 775 |
+} |