dotcloud/docker — pull request #1211 by vieux (2013-07-15 16:48:36+00:00)
Title: Store both logs in the same file

Here is a **first** improvement of the docker logs.

Now both logs, stdout and stderr are stored in the same file, as JSON, here an example:

{"log":"root@95701614e3b6:/# ls\r\n","stream":"stdout","time":"2013-07-15T15:45:36.916821934Z"}
{"log":"bin boot dev\u0009etc home lib\u0009lib64 media mnt opt\u0009proc root run sbin selinux\u0009srv sys tmp usr var\r\n","stream":"stdout","time":"2013-07-15T15:45:36.918411946Z"}
{"log":"root@95701614e3b6:/# pwd\r\n","stream":"stdout","time":"2013-07-15T15:45:37.884518169Z"}
{"log":"/\r\n","stream":"stdout","time":"2013-07-15T15:45:37.884609563Z"}
{"log":"root@95701614e3b6:/# ls\r\n","stream":"stdout","time":"2013-07-15T15:45:38.445316997Z"}
{"log":"bin boot dev\u0009etc home lib\u0009lib64 media mnt opt\u0009proc root run sbin selinux\u0009srv sys tmp usr var\r\n","stream":"stdout","time":"2013-07-15T15:45:38.446873535Z"}
{"log":"root@95701614e3b6:/# exit\r\n","stream":"stdout","time":"2013-07-15T15:45:38.829474305Z"}

As I said, it's a first step, the logs are still send as plain text from the server to the client and `docker logs` output in the same, but at least the logs are being sent in the right order (not full stdout then full stderr)

In a nutshell, I added a parameter to `AddWriter`, the stream name, like stdout/stderr. If there is no stream type (`""`) it's like before (it's used by pipes), if there is a stream name, It's buffered and written line by line in the JSON

Do you have any comment ?