Automatic Go function instrumentation tool that adds timing measurements and debug logging to your code.
go install github.com/alexshd/debuggefire/cmd/debuggefire@latestOr build from source:
git clone https://github.com/alexshd/debuggefire.git
cd debuggefire
go build -o debuggefire ./cmd/debuggefire# Add timing to a file
debuggefire add myfile.go
# Add to entire package recursively
debuggefire add ./pkg --recursive
# Remove instrumentation when done
debuggefire remove ./pkg --recursiveAfter instrumenting, install the required dependency:
go get github.com/lmittmann/tintTransforms this:
package main
func Calculate(x, y int) int {
return x + y
}Into this:
package main
import (
"log/slog"
"os"
"time"
"github.com/lmittmann/tint"
)
func init() {
slog.SetDefault(slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelDebug,
TimeFormat: "15:04:05.0000",
NoColor: false,
AddSource: true,
}),
))
}
func Calculate(x, y int) int {
__debuggefire_t0__ := time.Now()
defer func() {
slog.Debug("Calculate completed",
"duration", time.Since(__debuggefire_t0__))
}()
return x + y
}Add timing instrumentation to Go files.
debuggefire add [file or directory] [flags]
Flags:
-r, --recursive Process directories recursively
-b, --backup Create backup files (.bak) (default: true)Remove timing instrumentation from Go files.
debuggefire remove [file or directory] [flags]
Flags:
-r, --recursive Process directories recursively
-b, --backup Create backup files (.bak) (default: true)# Add instrumentation
debuggefire add ./mypackage --recursive
# Install required dependency
go get github.com/lmittmann/tint
# Run your code - see colored debug output!
go run main.goOutput example:
09:54:53 DBG myfile.go:19 Calculate completed duration=123.456µs
09:54:53 DBG myfile.go:27 ProcessData completed duration=2.345ms
When done debugging:
# Remove all instrumentation
debuggefire remove ./mypackage --recursive- Uses Go's AST parser for safe code manipulation
- Injects timing variable and defer statement at function start
- Automatically manages imports (time, log/slog, os, tint)
- Skips
init()functions to avoid recursion - Creates backups by default (disable with
--backup=false)
- Go 1.21+ (uses
log/slog) - Your project needs
github.com/lmittmann/tintafter instrumentation
go test ./...MIT