Show HN: Dlg – Zero-cost printf-style debugging for Go
I tend to use printf-style debugging as my primary troubleshooting method and only resort to gdb as a last resort.
While I like its ease of use printf debugging isn't without its annoyances, namely removing the print statements once you're done.
I used to use trace-level logging from proper logging libraries but adding trace calls in every corner quickly gets out of control and results in an overwhelming amount of output.
To scratch my own itch I created dlg - a minimal debugging library that disappears completely from production builds. Its API exposes just a single function, Printf [1].
dlg is optimized for performance in debug builds and, most importantly, when compiled without the dlg build tag, all calls are eliminated by the Go linker as if dlg was never imported.
For debug builds it adds optional stack trace generation configurable via environment variables or linker flags.
GitHub: https://github.com/vvvvv/dlg
Any feedback is much appreciated.
[1]: Actually two functions - there's also SetOutput.
No comments yet