mozilla/talkilla — pull request #171 by tOkeshu (2013-07-22 13:43:05+00:00)
Title: Server structured logs

For server side structured logs I choosed [Bunyan](https://github.com/trentm/node-bunyan/), a joyent product.
The library outputs JSON logs, have less dependencies than [Winston](https://github.com/flatiron/winston) and have a fairly good documentation.
Moreover Bunyan offers a CLI tool to filter and view the logs.

A typical log looks like this:

```
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"signin","msg":"","time":"2013-07-22T13:35:26.294Z","src":{"file":"talkilla/presence.js","line":146},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"connection","msg":"","time":"2013-07-22T13:35:26.353Z","src":{"file":"talkilla/presence.js","line":280,"func":"configureWs"},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"signin","msg":"","time":"2013-07-22T13:35:29.631Z","src":{"file":"talkilla/presence.js","line":146},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"connection","msg":"","time":"2013-07-22T13:35:29.661Z","src":{"file":"talkilla/presence.js","line":280,"func":"configureWs"},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"call:offer","msg":"","time":"2013-07-22T13:35:33.863Z","src":{"file":"talkilla/presence.js","line":207},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"call:accept","msg":"","time":"2013-07-22T13:35:38.417Z","src":{"file":"talkilla/presence.js","line":227},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"call:hangup","msg":"","time":"2013-07-22T13:35:43.205Z","src":{"file":"talkilla/presence.js","line":254},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"signout","msg":"","time":"2013-07-22T13:35:44.531Z","src":{"file":"talkilla/presence.js","line":156},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"disconnection","msg":"","time":"2013-07-22T13:35:44.534Z","src":{"file":"talkilla/presence.js","line":276},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"disconnection","msg":"","time":"2013-07-22T13:35:46.479Z","src":{"file":"talkilla/presence.js","line":276},"v":0}
{"name":"talkilla","hostname":"sanakan","pid":8987,"level":30,"type":"signout","msg":"","time":"2013-07-22T13:35:46.482Z","src":{"file":"talkilla/presence.js","line":156},"v":0}

```

I used the `type` field as a key. If we need to provide a human readable message we can use `msg` which is a builtin facility.

Take a look at the [documentation](https://github.com/trentm/node-bunyan/#features) for more information.