From 62263967b91ca841c43b980aec0ebc74ab2d838d Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Tue, 3 Dec 2013 06:18:01 +0000 Subject: [PATCH 1/3] Add stream flag to logs command --- commands.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index c86645eee3..f2377d8da8 100644 --- a/commands.go +++ b/commands.go @@ -1506,6 +1506,7 @@ func (cli *DockerCli) CmdDiff(args ...string) error { func (cli *DockerCli) CmdLogs(args ...string) error { cmd := cli.Subcmd("logs", "CONTAINER", "Fetch the logs of a container") + stream := cmd.Bool("stream", false, "Stream output") if err := cmd.Parse(args); err != nil { return nil } @@ -1525,7 +1526,15 @@ func (cli *DockerCli) CmdLogs(args ...string) error { return err } - if err := cli.hijack("POST", "/containers/"+name+"/attach?logs=1&stdout=1&stderr=1", container.Config.Tty, nil, cli.out, cli.err, nil); err != nil { + v := url.Values{} + v.Set("logs", "1") + v.Set("stdout", "1") + v.Set("stderr", "1") + if *stream { + v.Set("stream", "1") + } + + if err := cli.hijack("POST", "/containers/"+name+"/attach?"+v.Encode(), container.Config.Tty, nil, cli.out, cli.err, nil); err != nil { return err } return nil From 3ddbb36a84d5530b1f6b496ff8d79ade6f539267 Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Tue, 3 Dec 2013 07:17:07 +0000 Subject: [PATCH 2/3] Only stream logs when container is running --- commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands.go b/commands.go index f2377d8da8..699be1e4cf 100644 --- a/commands.go +++ b/commands.go @@ -1530,7 +1530,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error { v.Set("logs", "1") v.Set("stdout", "1") v.Set("stderr", "1") - if *stream { + if *stream && container.State.Running { v.Set("stream", "1") } From b699aee91f90b8390dfa6e8ef58e983fc8c4f3e5 Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Tue, 3 Dec 2013 20:35:22 +0000 Subject: [PATCH 3/3] Rename logs -stream to logs -f --- commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 699be1e4cf..c024333a65 100644 --- a/commands.go +++ b/commands.go @@ -1506,7 +1506,7 @@ func (cli *DockerCli) CmdDiff(args ...string) error { func (cli *DockerCli) CmdLogs(args ...string) error { cmd := cli.Subcmd("logs", "CONTAINER", "Fetch the logs of a container") - stream := cmd.Bool("stream", false, "Stream output") + follow := cmd.Bool("f", false, "Follow log output") if err := cmd.Parse(args); err != nil { return nil } @@ -1530,7 +1530,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error { v.Set("logs", "1") v.Set("stdout", "1") v.Set("stderr", "1") - if *stream && container.State.Running { + if *follow && container.State.Running { v.Set("stream", "1") }