Skip to content

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Jun 17, 2025

Summary

Added logic to parse --log-level flag in the runCLI function, ensuring the log level is set (warn, error, or silent) before any logs are printed.

Related Links

#5194

Checklist

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

Copilot AI review requested due to automatic review settings June 17, 2025 08:31
@netlify
Copy link

netlify bot commented Jun 17, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit fdf6af5
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/685127fadf8b1500082575b8
😎 Deploy Preview https://deploy-preview-5434--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: 77 (🟢 up 13 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

This PR fixes the log level handling in the CLI to ensure that the logger’s level is set before any logs are printed based on the provided command‐line flag.

  • Added logic in runCLI to process the --log-level flag and update the logger’s level appropriately.
  • Updated end-to-end tests to strip ANSI control characters from log outputs and verify correct log behavior for "info" and "warn" levels.

Reviewed Changes

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

File Description
packages/core/src/cli/index.ts Added flag parsing logic to set the logger level before any log is printed.
e2e/cases/cli/log-level/index.test.ts Updated tests to handle ANSI output and validate log behavior for different levels.
Comments suppressed due to low confidence (2)

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

  • Consider providing user feedback (such as a warning message) or a default fallback when an unsupported log level is provided to help clarify behavior.
if (logLevelIndex !== -1) {

e2e/cases/cli/log-level/index.test.ts:6

  • Consider adding a test case for an unsupported log level to ensure the logger maintains the expected default behavior when an invalid option is passed.
rspackOnlyTest('should run build command with log level: info', async () => {

@chenjiahan chenjiahan merged commit ef9f23b into main Jun 17, 2025
13 checks passed
@chenjiahan chenjiahan deleted the log_level_greet_0617 branch June 17, 2025 08:38
This was referenced Jun 20, 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