Add an extension point for exception logging middleware

For use with things like Sentry, Newrelic etc.

For more discussion of this issue see:

https://github.com/ckan/ckan/pull/1799