Support LogTape formatter selection - #867
Conversation
Allow createConsoleSink() to accept LogTape text and console formatters while preserving Optique's existing stream routing and default console output format. Text formatter output follows LogTape's console sink behavior by trimming a trailing line ending before calling the selected console method. Update the LogTape integration docs to show logfmtFormatter and refresh LogTape dependency locks so the documented formatter is available during Twoslash and package checks. #867 Assisted-by: Codex:gpt-5.5
Add textFormatter() for mapping jsonl, logfmt, color, and plain CLI values to LogTape's built-in text formatter functions. Export the parser from @optique/logtape and cover parsing, suggestions, formatting, and option integration. Document the new parser in the LogTape integration guide, package README, parser catalog, changelog, and Optique agent skill. #867 Assisted-by: Codex:gpt-5.5
Log output parsers now carry parsed or fixed LogTape text formatters through the LogOutput value, so createSink() can apply the selected format to both console and file sinks. The loggingOptions() preset exposes formatter at the top level because it configures the generated sink rather than only the output destination option. #867 Assisted-by: Codex:gpt-5.5
|
@codex review |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #867 +/- ##
=======================================
Coverage 93.41% 93.41%
=======================================
Files 75 76 +1
Lines 38503 38567 +64
Branches 9578 9593 +15
=======================================
+ Hits 35967 36028 +61
Misses 1733 1733
- Partials 803 806 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request upgrades the LogTape dependencies to version 2.2.2 and introduces support for custom text formatters. It adds a new textFormatter() value parser to map string identifiers to LogTape's built-in formatters, and integrates a formatter option into logOutput() and loggingOptions(). Additionally, createConsoleSink() and createSink() have been updated to support custom formatters, accompanied by comprehensive documentation updates and unit tests. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR adds formatter customization support to the Estimated code review effort: 4 (Complex) | ~50 minutes Possibly related PRs
Suggested labels: documentation, enhancement, logtape Suggested reviewers: dahlia 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/logtape/src/index.test.ts`:
- Around line 1052-1137: The console.log mock/restore pattern is duplicated in
multiple createConsoleSink tests, so extract a shared helper or switch to
node:test’s t.mock.method(console, "log") to centralize setup and auto-restore.
Update the affected tests around createConsoleSink to use that helper instead of
manually saving originalLog, assigning console.log, and wrapping each call in
try/finally.
In `@packages/logtape/src/preset.ts`:
- Around line 340-347: The formatter option parsing is duplicated between
preset.ts and output.ts’s withFormatter(), so the two implementations can drift.
Extract the shared optional(option(..., textFormatter(), { description:
message`Log output format.` })) construction into a small helper in output.ts,
then reuse that helper from the outputFormatter string branch in preset.ts and
from withFormatter() so the parsing logic stays in one place.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f1cd8a73-aa1e-4540-b4b5-81c867ac0469
⛔ Files ignored due to path filters (2)
deno.lockis excluded by!**/*.lockpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (15)
CHANGES.mddeno.jsondocs/.vitepress/theme/components/ParserCatalog.vuedocs/index.mddocs/integrations/logtape.mdpackages/core/skills/optique/SKILL.mdpackages/core/skills/optique/SKILL.test.tspackages/logtape/README.mdpackages/logtape/deno.jsonpackages/logtape/src/index.test.tspackages/logtape/src/index.tspackages/logtape/src/output.tspackages/logtape/src/preset.tspackages/logtape/src/textformatter.tspnpm-workspace.yaml
The formatter option parser now lives in one place, so the preset and logOutput() cannot drift in option names, descriptions, or value parsing. The console sink tests also share a small capture helper instead of repeating manual console.log restore blocks. #867 (comment) #867 (comment) Assisted-by: Codex:gpt-5.5
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces customizable text formatting capabilities to the @optique/logtape package. It adds a new textFormatter() value parser to map formatter names (jsonl, logfmt, color, plain) to LogTape's built-in formatters, and integrates a formatter option into logOutput(), loggingOptions(), createConsoleSink(), and createSink(). Additionally, it upgrades @logtape/file and @logtape/logtape dependencies to version 2.2.2 and updates the relevant documentation and test suites. There are no review comments provided, so I have no feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/logtape/src/output.ts`:
- Around line 260-268: The newly exported createTextFormatterOption function is
missing required JSDoc. Add a JSDoc block above createTextFormatterOption
describing its purpose, the long parameter, the returned
FluentParser/TextFormatter option, and include an `@throws` note for invalid
option names propagated through option().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7c124122-7c26-4a18-a430-f6c9de70e676
📒 Files selected for processing (3)
packages/logtape/src/index.test.tspackages/logtape/src/output.tspackages/logtape/src/preset.ts
The shared formatter option helper is exported for use by the preset, so it should carry the same API documentation as the rest of the package surface. #867 (comment) Assisted-by: Codex:gpt-5.5
|
/gemini review |
|
@codex review |
There was a problem hiding this comment.
Code Review
This pull request introduces text formatting capabilities to the @optique/logtape package, adding a new textFormatter() value parser and integrating a formatter option into logOutput(), loggingOptions(), and createConsoleSink(). The review feedback highlights a potential runtime error in toConsoleArgs if a custom formatter returns an unexpected type, suggesting explicit array validation to ensure robust argument spreading.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Custom formatter callbacks can still return unexpected values at runtime, especially from plain JavaScript callers. Normalize those values before spreading them into console methods so invalid returns do not turn into console sink failures. #867 (comment) Assisted-by: Codex:gpt-5.5
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for custom text and console formatters in the @optique/logtape package. It adds a new textFormatter() value parser to map string identifiers ("jsonl", `
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Why this shape
@optique/logtapealready had enough structure to choose a log level and an output destination, but the output format still had to be wired by hand. That left a gap between the parser result and the sink that actually writes records: the CLI could choose where logs go, but not how records are rendered there.This PR keeps that choice in the same data flow.
textFormatter()is a value parser for LogTape's built-in text formatter names, andLogOutputcan now carry the selected formatter tocreateSink(). That means a CLI can parse:and the selected formatter is applied later when the console or file sink is created.
The preset follows the same model, but keeps
formatterat theloggingOptions()top level:That placement is intentional. The formatter affects the generated sink, not only the
--log-outputdestination option. It also keeps formatter parsing available whenoutput.enabledisfalse, while fixed formatter values still apply to the default console output.How it works
textFormatter()acceptsjsonl,logfmt,color, andplain, returning LogTape'sjsonLinesFormatter,logfmtFormatter,ansiColorFormatter, anddefaultTextFormatter.logOutput()now acceptsformatter?: string | TextFormatter. A string adds a formatter option such as--log-format; aTextFormatterapplies a fixed formatter to whichever output the user selects.createSink()now passes formatter values through to both console and file sinks. The console path still lets explicitConsoleSinkOptions.formatteroverride a formatter carried byLogOutput, so call-site sink configuration remains the final say.The docs in docs/integrations/logtape.md and packages/logtape/README.md show both forms, and packages/core/skills/optique/SKILL.md now describes the LogTape integration as covering formatter/output options.
Verification
The branch has been checked with:
mise test:deno packages/logtapepnpm --filter @optique/logtape buildpnpm --filter @optique/logtape testpnpm --filter @optique/logtape test:bunpnpm buildin docs/mise check