Skip to content

feat: add support for custom logger#7357

Merged
chenjiahan merged 2 commits intomainfrom
custom_logger_0322
Mar 22, 2026
Merged

feat: add support for custom logger#7357
chenjiahan merged 2 commits intomainfrom
custom_logger_0322

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

This PR introduces the first part of customLogger support in @rsbuild/core.

It adds a config.customLogger option and wires it into the current Rsbuild instance so the logger can be associated with internal context and exposed through api.logger.

Scope

This is only the first part of the change.

In this PR, customLogger is connected to:

  • internal context
  • plugin API

It does not yet switch all internal core modules to use context.logger. That follow-up will be handled separately.

Related Links

#7353

Checklist

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

Copilot AI review requested due to automatic review settings March 22, 2026 11:40
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the initial support for a custom logger in @rsbuild/core. It enables users to configure their own logger, which is then integrated into the Rsbuild context and exposed via the plugin API. This change allows for greater flexibility and control over logging within Rsbuild.

Highlights

  • Custom Logger Integration: Introduces a config.customLogger option in @rsbuild/core, allowing users to provide their own logger instance.
  • API Exposure: Wires the custom logger into the Rsbuild instance, making it accessible through api.logger within plugins.
  • Context Association: Associates the custom logger with the internal context of Rsbuild, ensuring consistent logging throughout the build process.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for a custom logger through the config.customLogger option. The changes are well-implemented, correctly wiring the custom logger into the Rsbuild instance and exposing it via api.logger. The new e2e tests provide good coverage for this new functionality. The code modifications are clean and consistent with the goal of this feature. I have no further feedback as the changes look good.

Copy link
Copy Markdown
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 initial support for per-Rsbuild-instance loggers in @rsbuild/core by introducing config.customLogger, storing the chosen logger on the internal context, and exposing it to plugins via api.logger.

Changes:

  • Add customLogger?: Logger to RsbuildConfig and store the instance on InternalContext.
  • Wire api.logger to context.logger (instead of the shared default logger singleton).
  • Update/replace e2e coverage to validate default vs custom logger behavior and logLevel application.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/types/plugin.ts Updates plugin API docs for api.logger to describe per-instance behavior.
packages/core/src/types/context.ts Adds logger: Logger to InternalContext type.
packages/core/src/types/config.ts Introduces config.customLogger option in public config typing.
packages/core/src/initPlugins.ts Exposes context.logger through api.logger.
packages/core/src/createRsbuild.ts Chooses customLogger (or default) and applies logLevel to that instance.
packages/core/src/createContext.ts Stores selected logger on the created internal context; uses it for readonly-context assignment errors.
e2e/cases/plugin-api/logger/src/index.js Removes old logger API e2e fixture content.
e2e/cases/plugin-api/logger/index.test.ts Removes old e2e test that asserted api.logger === logger only.
e2e/cases/custom-logger/config-option/src/index.js Adds a minimal entry file for the new e2e case.
e2e/cases/custom-logger/config-option/index.test.ts Adds e2e tests for default/custom api.logger and logLevel behavior with customLogger.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2b5a12860

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chenjiahan chenjiahan merged commit 322af33 into main Mar 22, 2026
5 checks passed
@chenjiahan chenjiahan deleted the custom_logger_0322 branch March 22, 2026 12:01
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.

2 participants