Add a 'debug' setting to log error stacks

This adds a 'debug' setting to enable detailed stack
tracing. It makes debugging user reported errors much
easier.