feat: add namespaced debug logging inspired by npm's debug package - #83
Merged
Conversation
Add an internal/debug package that provides zero-cost namespaced debug logging, activated via GLEAN_DEBUG env var (with glob patterns) or the existing --verbose/-v flag. This makes auth failures, HTTP issues, and config resolution debuggable without code changes. Namespaces: auth:*, http:*, config:*, client:*, stream:*, session:*, tui:*. Example: GLEAN_DEBUG=auth:* glean auth login Key changes: - Wire the previously unused --verbose flag to debug.Enable() - Instrument HTTP transport (all 8 call sites via single RoundTrip) - Replace silent error swallowing in auth flow with debug logging - Add config/keyring resolution tracing (critical for macOS issues) - Add NDJSON parse error visibility in streaming chat - Show "Tip: re-run with -v" hint on auth failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes gocritic ifElseChain lint failure in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document that CI runs golangci-lint v2 with gocritic and other strict linters, and that local lint must pass before pushing. Adds explicit note about version mismatch risk. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
steve-calvert-glean
force-pushed
the
feat/debug-logging
branch
from
April 10, 2026 15:17
f6ec289 to
d29e8f6
Compare
rwjblue-glean
approved these changes
Apr 10, 2026
rwjblue-glean
left a comment
Member
There was a problem hiding this comment.
This looks great. It's a great base to build on even more stuff if we want to in the future as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/debugpackage providing zero-cost namespaced debug logging, inspired by npm'sdebugpackageGLEAN_DEBUGenv var with glob patterns (e.g.GLEAN_DEBUG=auth:*) or--verbose/-vflag_ = err) with debug-logged best-effort operationsNamespaces
auth:loginauth:resolve-hostauth:discoveryauth:dcrauth:tokenauth:emailhttp:requesthttp:responseclient:resolveconfig:loadconfig:keyringstream:connectstream:parsesession:persisttui:initExample
Test plan
go test ./... -count=1— 419 tests passgolangci-lint run— cleanmise run build— binary builds./glean auth statusshows no debug outputGLEAN_DEBUG=*— full trace to stderrGLEAN_DEBUG=config:keyring— only keyring logs shownGLEAN_DEBUG='*,-config:keyring'— negation works./glean -v auth status— verbose flag enables all debuggo test ./internal/debug/... -race🤖 Generated with Claude Code