feat(cli): add --log-level flag to CLI commands#2546
Draft
maastrich wants to merge 6 commits into
Draft
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- 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 Report❌ Patch coverage is ❌ 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. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Closes #2311
Adds a
--log-leveloption to all CLI commands (extract,extract-template,extract-experimental,compile) to control output verbosity.Log levels
silenterrorwarninginfoverbose--verboseis kept as a backward-compatible alias for--log-level=verbose. If both--verboseand a conflicting--log-levelare passed,verbosewins with a warning.Implementation
packages/cli/src/api/logger.ts— newLogLeveltype,initLogger(logLevel)factory returning aLoggerwith no-op methods for suppressed levels. No per-call level checks scattered through the codebase.packages/cli/src/api/workerLogger.ts— implements the fullLoggerinterface;warn/info/verboseare no-ops (errors collected and flushed to the main thread as before).logLevelin their options type and callinitLogger(options.logLevel)at the top ofcommand().compileLocale.ts— per-locale success path now correctly useslogger.verbose()instead of the misnamedlogger.error()with green text.Test plan
logLevel=silent(no output),logLevel=silenton failure (still no output),logLevel=erroron failure (errors only, no info)lingui compile --log-level=silentproduces no outputlingui extract --log-level=errorsuppresses stats but shows errorslingui compile --verbose --log-level=errorwarns and uses verbose🤖 Generated with Claude Code