Add an optional hook for logging requests and responses

to: @hcai @jasonkb