Hasty Briefsbeta

Bilingual

Show HN: Dlg – Zero-cost printf-style debugging for Go

9 months ago
  • #logging
  • #debugging
  • #golang
  • dlg provides a minimal API for printf-style debugging and vanishes from production builds.
  • Zero-cost abstraction: logging calls disappear entirely from production binaries.
  • Near-zero overhead in debug builds with performance-focused design.
  • Runtime-configurable stack trace generation (DLG_STACKTRACE=ERROR/ALWAYS).
  • Concurrent-safe by design; custom writers need to implement sync.Locker.
  • Minimalist API with just two functions: Printf and SetOutput.
  • When compiled without the dlg tag, all logging calls are eliminated with no runtime overhead.
  • Debug builds show detailed logs and stack traces based on runtime configuration.
  • Custom writers can be made concurrency-safe by implementing sync.Locker.
  • Verifiable zero-cost: compiler completely eliminates dlg calls in production builds.