A lightweight, colorful, and flexible debugging utility for Go — inspired by debug in Node.js.
debugo
provides namespaced, timestamped, and color-coded logging with support for inclusion/exclusion patterns and pluggable output streams.
- ✅ Namespaced debug logs (
namespace:subspace
) - 🎨 Automatic and consistent color assignment per namespace
- 🕒 Time elapsed since last log (e.g.,
+3ms
) - 🧪 Wildcard-based inclusion/exclusion filtering (
*
,-namespace:*
) - 🔐 Thread-safe logging with
sync.RWMutex
- 🧰 Custom timestamp format and output writer support
go get github.com/yosev/debugo
package main
import (
"github.com/yosev/debugo"
)
func main() {
debugo.SetNamespace("*") // Enable all logs
log := debugo.New("app")
log.Debug("Hello, debugo!")
sublog := log.Extend("submodule")
sublog.Debug("Detailed submodule log")
}
15:04:05.123 app Hello, debugo! +0ms
15:04:05.123 app:submodule Detailed submodule log +1ms
Function | Description |
---|---|
New(name string) |
Creates a new debugger for the namespace |
Extend(name string) |
Creates a sub-namespace logger |
Method | Description |
---|---|
Debug(args ...any) |
Print values to the output stream |
Debugf(format, ...) |
Formatted output like fmt.Printf |
debugo.SetNamespace("*") // Enable all namespaces
debugo.SetNamespace("app:*") // Enable only app and submodules
debugo.SetNamespace("api:*, -api:auth") // Enable `api:*` except `api:auth`
debugo.SetNamespace("") // Disable all logging
Supports wildcards (*
) and negation (-
).
f, _ := os.Create("debug.log")
debugo.SetOutput(f) // Send logs to a file instead of stdout
You can also set it back to os.Stdout
or os.Stderr
as needed.
debugo.SetTimestamp(&debugo.Timestamp{
Format: "15:04:05", // HH:MM:SS (default)
})
Use any Go-compliant time format layout.
go test -v -race ./...
If using make
:
make test
debugo/
├── debugo.go // main library
├── color.go // color functions
├── runtime.go // global runtime configuration
├── namespace.go // namespace functions
├── time.go // timestamp functions
└── write.go // output writer
Contributions are very welcome!
- Fork this repo
- Create a new branch:
git checkout -b feature-name
- Make changes and commit:
git commit -am 'Add feature'
- Push:
git push origin feature-name
- Create a pull request
MIT License © 2025 YoSev