Centralize BD_DEBUG logging into internal/debug package
- Created internal/debug package with Enabled(), Logf(), Printf()
- Added comprehensive unit tests for debug package
- Replaced 50+ scattered os.Getenv("BD_DEBUG") checks across 9 files
- Centralized debug logic for easier maintenance and testing
- All tests passing, behavior unchanged
Closes bd-fb95094c.5
This commit is contained in:
24
internal/debug/debug.go
Normal file
24
internal/debug/debug.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var enabled = os.Getenv("BD_DEBUG") != ""
|
||||
|
||||
func Enabled() bool {
|
||||
return enabled
|
||||
}
|
||||
|
||||
func Logf(format string, args ...interface{}) {
|
||||
if enabled {
|
||||
fmt.Fprintf(os.Stderr, format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func Printf(format string, args ...interface{}) {
|
||||
if enabled {
|
||||
fmt.Printf(format, args...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user