Skip to content

Logger: Honor --loglevel for npmlog output#33776

Merged
valentinpalkovic merged 1 commit into
storybookjs:nextfrom
LouisLau-art:fix/loglevel-flag-works
Feb 5, 2026
Merged

Logger: Honor --loglevel for npmlog output#33776
valentinpalkovic merged 1 commit into
storybookjs:nextfrom
LouisLau-art:fix/loglevel-flag-works

Conversation

@LouisLau-art
Copy link
Copy Markdown

@LouisLau-art LouisLau-art commented Feb 5, 2026

Fixes #22061.

  • Ensure logger.setLogLevel updates both the new logger and the legacy npmlog instance (with sensible level mapping: trace->silly, debug->verbose).
  • Make --debug actually take effect (forces loglevel=debug).
  • Validate --loglevel values via commander choices.

Tests:

  • yarn --cwd code vitest run --config core/vitest.config.ts core/src/node-logger/index.test.ts

Summary by CodeRabbit

  • Bug Fixes

    • Improved log level option handling for more reliable CLI configuration.
    • Enhanced consistency in log level synchronization across logging systems.
  • Tests

    • Added test coverage for log level synchronization and configuration consistency.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Refactored CLI log level option using Commander's Option API with explicit choices and default values. Introduced log level translation mapping between internal log levels and npm-log equivalents, centralized level management logic, and added synchronization tests.

Changes

Cohort / File(s) Summary
CLI Option Refactoring
code/core/src/bin/core.ts
Migrated from .option() to .addOption(new Option()) API for log level configuration; imported Option from commander; updated preAction logic to compute log level with debug flag override.
Logger Level Management
code/core/src/node-logger/index.ts
Introduced toNpmLogLevel mapping function to translate internal log levels (trace→silly, debug→verbose); added setLoggerLevel helper to centralize npmLog and logger level synchronization; updated setLevel and setLogLevel methods to use the helper.
Logger Tests
code/core/src/node-logger/index.test.ts
Added two new tests verifying log level synchronization with npmlog and consistency between setLevel and setLogLevel methods.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LouisLau-art
Copy link
Copy Markdown
Author

Friendly ping for review when you have time — this aligns --loglevel with npmlog output so the CLI flag consistently controls logging verbosity.

@valentinpalkovic valentinpalkovic changed the title fix(core): honor --loglevel for npmlog output Logger: honor --loglevel for npmlog output Feb 5, 2026
@valentinpalkovic valentinpalkovic self-assigned this Feb 5, 2026
@valentinpalkovic valentinpalkovic changed the title Logger: honor --loglevel for npmlog output Logger: Honor --loglevel for npmlog output Feb 5, 2026
@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Feb 5, 2026
@valentinpalkovic valentinpalkovic merged commit 02fdf2a into storybookjs:next Feb 5, 2026
119 of 125 checks passed
valentinpalkovic added a commit that referenced this pull request Feb 5, 2026
Logger: honor --loglevel for npmlog output
(cherry picked from commit 02fdf2a)
@github-actions github-actions Bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: --loglevel has no impact on output during build

2 participants