Hacker News new | ask | show | jobs
by chriswarbo 1261 days ago
> It is helpful if you can selectively switch on verbose logging by user or by API endpoint.

We currently use two log levels:

- When 'debug = true', debug logs are printed immediately (like a DEBUG log level)

- When 'debug = false', debug logs go into a buffer: if the request-handler succeeds, its debug buffer gets discarded. If it catches an exception, the buffer gets printed.

This avoids the main problem of log levels, which is having to guess up-front which level we might want (and inevitably get it wrong, and have to try re-creating a problem with more verbose logging!)

1 comments

Nice! It sounds like you would do well to capture the debug output if a request handler takes an unusually long time to return (not just if an uncaught exception occurs).