Skip to content

--debug flag defined but never wired to logger level #497

@beep-boopp

Description

@beep-boopp

Describe the bug

The --debug / -d flag is registered in the CLI and shows up in --help, but initLogger never reads it. The log handler is hardcoded to slog.LevelInfo regardless of whether --debug is passed.

All 13 Debug() calls across setup/match.go, setup/find.go, instrument/toolexec.go, and instrument/match.go are silently filtered out. There's no way to enable debug output from the CLI.

Additionally, all log output (including debug) only goes to debug.log in the work directory — even if the flag worked, a user would have to dig through a temp directory to see it.

To Reproduce

otelc --debug go build ./...
# vs
otelc go build ./...
# identical behavior — debug flag has no effect

initLogger at tool/cmd/main.go:121 hardcodes the level:

handler := slog.NewTextHandler(writer, &slog.HandlerOptions{
    Level: slog.LevelInfo,  // never changes, --debug is not read
})

The flag has actually never worked — it was originally introduced in #50 as "-debug" (extra dash, would render as ---debug). #281 fixed the typo but didn't catch that it was never wired to the logger.

Expected behavior

otelc --debug should set the logger to slog.LevelDebug so existing Debug() calls actually produce output. Debug output should also be teed to stderr so it's visible in the terminal, consistent with how go build -x and other Go toolchain tools surface verbose output.

Additional context

Stumbled across this while looking at CLI output behavior. All the debug instrumentation is already written — rule source resolution, CGO mappings, matched rule sets, import additions — it's just unreachable.

I can open a PR shortly with the fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions