Skip to content

Commit a9d355b

Browse files
authored
Add LLM instructions for how to use the logger (#60632)
1 parent 2540901 commit a9d355b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/instructions/code.instructions.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,33 @@ Run the following commands to validate your changes:
9494
8. Validate that any new or changed tests pass. See "Tests".
9595
9. Validate that these changes meet our guidelines. See "Guidelines".
9696
10. If you are running in agentic mode, _stop_ at this point and request review before continuing. Suggest how the human should review the changes.
97-
11. If a branch and pull request already exist, commit and push, then _concisely_ comment on the pull request that you are GitHub Copilot and what changes you made and why.
97+
11. If a branch and pull request already exist, commit and push, then _concisely_ comment on the pull request that you are GitHub Copilot and what changes you made and why.
9898
12. If this is new work and no pull request exists yet, make a pull request:
9999
- label "llm-generated"
100100
- draft mode
101101
- include "fixes owner/repo#issue" or "towards owner/repo#issue" as appropriate
102102
13. If you are in agentic mode, offer to wait for CI to run and check that it passes. If the human agrees, verify in CI: `sleep 240 && gh pr checks $number`. Address all failures, don't assume they're flakes.
103103
14. If you are in agentic mode, offer to do any or all of:
104104
- mark the pull request as ready,
105-
- assign the issue to the human if it is not already assigned,
105+
- assign the issue to the human if it is not already assigned,
106106
- _concisely_ comment on the issue explaining the change, indicating you are GitHub Copilot.
107+
108+
## Logger
109+
110+
Use `createLogger` from `@/observability/logger` instead of `console.log` in server-side code.
111+
112+
```typescript
113+
import { createLogger } from "@/observability/logger";
114+
115+
const logger = createLogger(import.meta.url);
116+
117+
logger.debug("Detailed tracing");
118+
logger.info("Normal event", { userId });
119+
logger.warn("Recoverable issue");
120+
logger.error("Failure", { error });
121+
```
122+
123+
- Pass a plain object as the second argument to add structured context (emitted as logfmt in production).
124+
- Never log secrets, tokens, or PII.
125+
- Create loggers once at module scope, not inside functions.
126+
- Do not use the logger in scripts (locally-run code); `console.log` is fine there.

0 commit comments

Comments
 (0)