A lightweight, colorful, and flexible logging 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
- 🎨 JSON output support
- 🎨 Fields output support
go get github.com/yosev/debugopackage 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("api:*") // Enable 'api' with sub spaces
debugo.SetNamespace("api:*, -api:auth") // Enable `api:*` with sub spaces except `api:auth`
debugo.SetNamespace("api:?") // Enable `api` with optional with sub spaces
debugo.SetNamespace("") // Disable all loggingSupports wildcards (*), optional sub spcaces (?), and negation (-).
f, _ := os.Create("debug.log")
debugo.SetOutput(f) // Send logs to a file instead of stdoutYou 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 testdebugo/
├── 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
