Skip to content

fix(logger): configure log level and format with env vars - #65

Merged
kyscott18 merged 1 commit into
mainfrom
fix/logger-env
Oct 14, 2026
Merged

kyscott18 merged 1 commit into
mainfrom
fix/logger-env

Conversation

@kyscott18

@kyscott18 kyscott18 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add TYPEWRITER_LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error". The default is "info".
  • Add TYPEWRITER_LOG_FORMAT: "pretty" | "json". The default is "json" when NODE_ENV is "production", else "pretty".
  • An invalid value throws when the module loads. An empty value uses the default.
  • Document both variables under createTypewriter() in the READMEs.
  • The harness benchmark now sets TYPEWRITER_LOG_LEVEL=info and does not mute console.log/console.debug. All hot-path logs are Debug, so nothing prints at info.

Behavior changes

  • The default minimum level changes from Debug to Info. Set TYPEWRITER_LOG_LEVEL=debug to see the old logs.
  • The benchmark no longer includes the cost of formatting Debug logs. Do not compare its numbers directly with older runs.

Test plan

  • tsc --noEmit and bun test in packages/typewriter (79 pass)
  • Manual check of the default, debug, production json, the pretty override, and an invalid value
  • bun run benchmark passes the test. The script still exits with code 1 because of a halt: OutOfGas(MemoryLimit) revert that also occurs on main.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking request to test the new logging settings.

Fix All in Claude CodeFindings

  1. P2 Logging settings lack tests ▶
Fix with agent prompt
### Issue 1
packages/typewriter/src/logger.ts:27-39
The new environment settings have no automated tests. A later change could silently hide logs or stop server startup without failing the suite.

Add tests that import `logger.ts` in a fresh process for each case: unset and empty values, supported levels and formats, production defaults, and invalid values. Fresh processes matter because the module reads these settings only once.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds environment settings for log level and format, documents them in both READMEs, and removes console muting from the benchmark.

  • Typewriter logs use the level and format set in the environment.
  • The harness benchmark measures runs without muting console methods.

Reviews (1) · Last reviewed commit: "fix(logger): configure log level and for..." · Reviewed by Greptile

Add TYPEWRITER_LOG_LEVEL ("trace" | "debug" | "info" | "warn" | "error",
default "info") and TYPEWRITER_LOG_FORMAT ("pretty" | "json", default
"json" when NODE_ENV is "production", else "pretty"). An invalid value
throws when the module loads.

The harness benchmark now runs at "info" and does not mute the console.
@kyscott18
kyscott18 merged commit 09e3106 into main Oct 14, 2026
8 checks passed
Comment on lines +27 to +39
function readEnv<const T extends string>(
name: string,
values: readonly T[],
fallback: T,
): T {
const value = process.env[name];
if (value === undefined || value === "") return fallback;
if (!(values as readonly string[]).includes(value)) {
throw new Error(
`${name} must be one of ${values.map((v) => `"${v}"`).join(", ")}, got "${value}"`,
);
}
return value as T;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Logging settings lack tests

The new environment settings have no automated tests. A later change could silently hide logs or stop server startup without failing the suite.

Add tests that import logger.ts in a fresh process for each case: unset and empty values, supported levels and formats, production defaults, and invalid values. Fresh processes matter because the module reads these settings only once.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/typewriter/src/logger.ts
Line: 27-39

Comment:
**Logging settings lack tests**

The new environment settings have no automated tests. A later change could silently hide logs or stop server startup without failing the suite.

Add tests that import `logger.ts` in a fresh process for each case: unset and empty values, supported levels and formats, production defaults, and invalid values. Fresh processes matter because the module reads these settings only once.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant