Extract logging and stats into a middleware

Instead of capturing stats all over the place, rely on the env object
and middleware placement to capture everything we need to log requests
and responses.

The logger middleware is loaded between the decoder and encoder.
Merge pull request #163 from localshred/logger_middleware

Extract logging and stats into a middleware