Skip to content

feat(core): add logLevel config#5423

Merged
chenjiahan merged 1 commit intomainfrom
log_level_0615
Jun 16, 2025
Merged

feat(core): add logLevel config#5423
chenjiahan merged 1 commit intomainfrom
log_level_0615

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Jun 15, 2025

Summary

Adding support for configurable log levels, which is syntactic sugar for logger.level = '...'.

It is worth noting that the current logLevel still has some limitations. Since the logger object is a global singleton, if the user creates multiple Rsbuild instances at the same time, they must set the same logLevel value.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings June 15, 2025 12:52
@netlify
Copy link

netlify bot commented Jun 15, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 19087ca
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/684ec1f9bc909300082d6354
😎 Deploy Preview https://deploy-preview-5423--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 54 (🔴 down 21 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new logLevel configuration option to control logger verbosity and integrates it into the core and CLI entrypoints.

  • Introduce logLevel in the public RsbuildConfig interface with supported levels 'info', 'warn', and 'error'.
  • Apply config.logLevel to logger.level during Rsbuild initialization.
  • Replace console.log() in the CLI bootstrap with logger.log() for consistency.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/core/src/types/config.ts Added logLevel field and its JSDoc to RsbuildConfig.
packages/core/src/createRsbuild.ts Set logger.level based on config.logLevel.
packages/core/src/cli/index.ts Swapped console.log() for logger.log() to emit a blank line.
Comments suppressed due to low confidence (3)

packages/core/src/createRsbuild.ts:170

  • There are no tests verifying that setting logLevel updates logger.level. Consider adding a unit test to cover this new behavior.
if (config.logLevel) {

packages/core/src/types/config.ts:1785

  • [nitpick] The logLevel option is introduced here, but external docs or the README should be updated to show how to configure and use this option in practice.
logLevel?: 'info' | 'warn' | 'error';

packages/core/src/cli/index.ts:27

  • Calling logger.log() with no arguments may not produce a blank line as console.log() did. Consider using logger.log('') or extending the logger API to explicitly support empty-line logging.
logger.log();

@chenjiahan chenjiahan merged commit 7452ef4 into main Jun 16, 2025
13 checks passed
@chenjiahan chenjiahan deleted the log_level_0615 branch June 16, 2025 01:22
This was referenced Jun 17, 2025
@chenjiahan chenjiahan mentioned this pull request Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant