docs: add guidance on using pkg/logger for debug instrumentation - #51163
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
docs: suggest using pkg/logger for debug logs in AGENTS.md
docs: add guidance on using pkg/logger for debug instrumentation
Aug 7, 2026
pelikhan
marked this pull request as ready for review
August 7, 2026 19:13
Contributor
There was a problem hiding this comment.
Pull request overview
Adds contributor guidance for debug instrumentation, but the documented example does not match the current pkg/logger API.
Changes:
- Documents logger creation and namespace conventions.
- Adds example debug logging calls.
- Explains
DEBUG-gated output.
Show a summary per file
| File | Description |
|---|---|
AGENTS.md |
Adds guidance for instrumenting Go code with pkg/logger. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Suppressed comments (2)
AGENTS.md:120
*logger.Loggerhas noDebugmethod; it only providesPrintandPrintf(pkg/logger/logger.go:118-142), so copying this canonical example will not compile. Also use a package-unique variable name, as established by examples such aspkg/parser/import_error.go:12, so multi-file packages do not redeclarelog.
var log = logger.New("cli:my_package") // one per file/package, at package scope
func doSomething() {
log.Debug("starting operation", "key", value)
AGENTS.md:127
- The logger does not accept structured key/value fields:
Printdelegates tofmt.Sprint, whilePrintfaccepts a format string. Instructing callers to pass pairs after the message describes an API that does not exist and would not produce reliably formatted fields.
- Pass structured key/value pairs after the message for queryable context.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
|
|
||
| ### Adding debug logs | ||
|
|
||
| When adding new debug instrumentation to Go code, use `pkg/logger` — **never** `fmt.Println`, `log.Printf`, or other ad-hoc output: |
Copilot created this pull request from a session on behalf of
pelikhan
August 7, 2026 19:16
View session
Contributor
|
🎉 This pull request is included in a new release. Release: |
This was referenced Aug 7, 2026
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.
AGENTS.mdhad no guidance on adding debug logs — only on enabling them. This left contributors without a clear signal to usepkg/loggerinstead of ad-hocfmt.Println/log.Printf.Changes
AGENTS.md— new "Adding debug logs" subsection under Debugging & Logging:var log = logger.New("namespace")at package scope, calllog.Debug(...)with structured key/value pairs.cli:,workflow:,mcp:, etc.).DEBUG-gated — zero noise in normal operation.