Skip to content

feat(cli): add --log-level flag to CLI commands#2546

Draft
maastrich wants to merge 6 commits into
lingui:mainfrom
maastrich:feat/cli-silent-flag
Draft

feat(cli): add --log-level flag to CLI commands#2546
maastrich wants to merge 6 commits into
lingui:mainfrom
maastrich:feat/cli-silent-flag

Conversation

@maastrich

Copy link
Copy Markdown
Contributor

Summary

Closes #2311

Adds a --log-level option to all CLI commands (extract, extract-template, extract-experimental, compile) to control output verbosity.

Log levels

Level Output
silent No output at all
error Errors only
warning Errors and warnings (e.g. experimental feature notice)
info Normal informational output — default
verbose All output including per-locale compilation paths and worker pool size

--verbose is kept as a backward-compatible alias for --log-level=verbose. If both --verbose and a conflicting --log-level are passed, verbose wins with a warning.

Implementation

  • packages/cli/src/api/logger.ts — new LogLevel type, initLogger(logLevel) factory returning a Logger with no-op methods for suppressed levels. No per-call level checks scattered through the codebase.
  • packages/cli/src/api/workerLogger.ts — implements the full Logger interface; warn/info/verbose are no-ops (errors collected and flushed to the main thread as before).
  • All 4 CLI command files receive logLevel in their options type and call initLogger(options.logLevel) at the top of command().
  • compileLocale.ts — per-locale success path now correctly uses logger.verbose() instead of the misnamed logger.error() with green text.

Test plan

  • Existing compile test suite passes (15/15)
  • New tests for logLevel=silent (no output), logLevel=silent on failure (still no output), logLevel=error on failure (errors only, no info)
  • Manual test: lingui compile --log-level=silent produces no output
  • Manual test: lingui extract --log-level=error suppresses stats but shows errors
  • Manual test: lingui compile --verbose --log-level=error warns and uses verbose

🤖 Generated with Claude Code

maastrich and others added 2 commits May 7, 2026 17:54
Adds a --silent option to all CLI commands (extract, extract-template,
extract-experimental, compile) that suppresses informational console output
while still emitting errors. Useful in CI pipelines and build scripts where
output noise makes it harder to spot real failures.

Closes lingui#2311

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduces a proper log level hierarchy (silent|error|warning|info|verbose)
across all CLI commands (extract, extract-template, extract-experimental,
compile). Adds initLogger() utility in api/logger.ts that returns no-op
methods for suppressed levels. --verbose is kept as a backward-compatible
alias for --log-level=verbose, with a warning if it conflicts.

- silent: no output at all
- error: errors only
- warning: errors + warnings (used for experimental feature notice)
- info: normal output, default
- verbose: all output including per-locale compilation paths and pool size

Closes lingui#2311

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented May 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
js-lingui Ready Ready Preview May 11, 2026 2:07pm

Request Review

- Add logLevel to all test call sites in index.test.ts and translationIO.test.ts
- Use console.log for logger.warn to preserve stdout behavior (consistent
  with existing CLI convention of styling-based severity signaling)
- Fix docs formatting via Prettier

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 49.49495% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.52%. Comparing base (6bb8983) to head (74cb680).
⚠️ Report is 329 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/lingui-extract.ts 34.61% 13 Missing and 4 partials ⚠️
packages/cli/src/lingui-compile.ts 35.29% 7 Missing and 4 partials ⚠️
packages/cli/src/lingui-extract-experimental.ts 38.46% 4 Missing and 4 partials ⚠️
packages/cli/src/lingui-extract-template.ts 38.46% 4 Missing and 4 partials ⚠️
packages/cli/src/api/workerLogger.ts 0.00% 5 Missing ⚠️
packages/cli/src/api/compile/compileLocale.ts 85.71% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (49.49%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2546       +/-   ##
===========================================
+ Coverage   77.05%   88.52%   +11.47%     
===========================================
  Files          84      119       +35     
  Lines        2157     3426     +1269     
  Branches      555     1003      +448     
===========================================
+ Hits         1662     3033     +1371     
+ Misses        382      342       -40     
+ Partials      113       51       -62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Add a silent or log-level option for the CLI

1 participant