Skip to content

Comments

feat: port getLogFilter helper from Rollup for advanced log filtering#6890

Merged
sapphi-red merged 3 commits intorolldown:mainfrom
taearls:5848/missing-get-log-filter-helper
Dec 15, 2025
Merged

feat: port getLogFilter helper from Rollup for advanced log filtering#6890
sapphi-red merged 3 commits intorolldown:mainfrom
taearls:5848/missing-get-log-filter-helper

Conversation

@taearls
Copy link
Contributor

@taearls taearls commented Nov 8, 2025

Closes #5848

Implement the missing getLogFilter helper function to achieve full Rollup API compatibility for advanced log filtering.

The helper function supports:

  • Simple property matching (code:FOO)
  • Wildcard patterns (code:A, code:B, code:C)
  • Inverted filters (!code:FOO)
  • AND conditions (code:FOO&plugin:bar)
  • OR conditions (multiple filters in array)
  • Nested properties (foo.bar:baz)
  • Object and number matching

Usage:

import getLogFilter from 'rolldown/getLogFilter';

const logFilter = getLogFilter(['code:FOO', 'code:BAR']);

export default {
  onLog(level, log, handler) {
    if (logFilter(log)) {
      handler(level, log);
    }
  }
};

Implementation details:

  • Single file implementation in src/get-log-filter.ts
  • Comprehensive test suite with 9 tests covering all edge cases

@hyf0
Copy link
Member

hyf0 commented Nov 9, 2025

I'm hesitating because rolldown doesn't expose much error details as rollup did, so I'm thinking the value of having this. @sapphi-red cc

@sapphi-red
Copy link
Member

I think there aren't much downside to have this (the upside is rollup compat).

As a side note, we probably need to add a hook filter to onLog as we have to call onLog for all logs (we filter out the info messages with logLevel beforehand, but onLog can raise the severity).

taearls and others added 2 commits November 14, 2025 13:11
Implement the missing `getLogFilter` helper function to achieve full
Rollup API compatibility for advanced log filtering.

The helper function supports:
- Simple property matching (code:FOO)
- Wildcard patterns (code:*A, code:B*, code:*C*)
- Inverted filters (!code:FOO)
- AND conditions (code:FOO&plugin:bar)
- OR conditions (multiple filters in array)
- Nested properties (foo.bar:baz)
- Object and number matching

Usage:
```javascript
import getLogFilter from 'rolldown/getLogFilter';

const logFilter = getLogFilter(['code:FOO', 'code:BAR']);

export default {
  onLog(level, log, handler) {
    if (logFilter(log)) {
      handler(level, log);
    }
  }
};
```

Implementation details:
- Single file implementation in src/get-log-filter.ts
- Exports both default and named exports for flexibility
- Comprehensive test suite with 9 tests covering all edge cases
- Follows Rolldown's established export patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@taearls taearls force-pushed the 5848/missing-get-log-filter-helper branch from d161912 to d582e93 Compare November 14, 2025 19:11
@taearls
Copy link
Contributor Author

taearls commented Nov 14, 2025

I think there aren't much downside to have this (the upside is rollup compat).

As a side note, we probably need to add a hook filter to onLog as we have to call onLog for all logs (we filter out the info messages with logLevel beforehand, but onLog can raise the severity).

Hi! I'm not sure I understand the ask. Does onLog need to be called from within getLogFilter?

Copy link
Member

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

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

LGTM. See if others wanna do some tweaks.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

LGTM

For attribution, it's worth noting that much of the implementation is derived from Rollup.

@sapphi-red sapphi-red enabled auto-merge (squash) December 15, 2025 12:13
@sapphi-red sapphi-red merged commit 27d96ac into rolldown:main Dec 15, 2025
20 checks passed
This was referenced Dec 17, 2025
shulaoda added a commit that referenced this pull request Dec 17, 2025
## [1.0.0-beta.55] - 2025-12-17

### 🚀 Features

- add validation errors for incompatible `inlineDynamicImports` options (#7539) by @Copilot
- rolldown_plugin_vite_reporter: truncate long importer lists in ineffective dynamic import warnings (#7528) by @Copilot
- export `memfs` from `rolldown/experimental` for browser builds (#7490) by @Copilot
- implement `postBanner` and `postFooter` (#7487) by @sevenc-nanashi
- port getLogFilter helper from Rollup for advanced log filtering (#6890) by @taearls
- dev: initialize `rolldown_plugin_lazy_compilation` (#7488) by @hyf0
- enable `experimental.transform_hires_sourcemap: 'boundary'` by default (#7478) by @sapphi-red
- apply merge CJS namespace optimizations more generally (#7475) by @sapphi-red

### 🐛 Bug Fixes

- avoid panic on invalid values for `output.exports`, `output.format`, `output.hash_characters` (#7542) by @sapphi-red
- handle `__proto__` export for module namespace correctly (#7534) by @sapphi-red
- handle `__proto__` export correctly (#7533) by @sapphi-red
- rolldown_plugin_vite_resolve: acquire resolver lock before package json resolution (#7524) by @sapphi-red
- disable syntax transform optimization for `minify: 'dce-only'` (#7520) by @sapphi-red
- arrow function expression keep names (#7519) by @IWANABETHATGUY
- skip symbols that are imported from other module when deconflicting module symbols (#7510) by @IWANABETHATGUY
- preserve class names in assignment expressions with keepNames option (#7491) by @IWANABETHATGUY
- accessor with decorators should be kept (#7499) by @Copilot
- rolldown_plugin_vite_reporter: support `Infinity` for chunk_limit (#7497) by @shulaoda
- change filename template validation errors from UNHANDLEABLE_ERROR to INVALID_OPTION (#7472) by @Copilot
- `no entry found for key` error when merging CJS namespace exports (#7474) by @sapphi-red
- generate output with syntax error when wrapped esm module using tla syntax (#7468) by @IWANABETHATGUY

### 🚜 Refactor

- dev: rename `experimental.hmr` to `experimental.devMode` (#7527) by @hyf0
- pass addon option to rust as it is (#7526) by @hyf0
- remove unused stmtinfo meta flag (#7518) by @IWANABETHATGUY

### 📚 Documentation

- clarify `closeBundle` behavior (#7525) by @sapphi-red

### 🧪 Testing

- add tests for static string postBanner and postFooter (#7516) by @Copilot
- disable pluginTimings in Rust integration tests to avoid snapshot noise (#7485) by @shulaoda
- port Rollup JSX tests to `crates/rolldown/tests/rollup` (#7480) by @sapphi-red
- re-triage some esbuild JSX preserve tests (#7479) by @sapphi-red
- disable pluginTimings by default to avoid snapshot noise (#7471) by @shulaoda

### ⚙️ Miscellaneous Tasks

- mark feature that will not be supported as ignored in rollup test status (#7535) by @sapphi-red
- support `banner`/`footer`/`intro`/`outro` for config variants (#7532) by @sapphi-red
- `dce/dce_of_decorators` esbuild test is now passing (#7531) by @sapphi-red
- deps: update github-actions (major) (#7495) by @renovate[bot]
- deps: update npm packages (#7493) by @renovate[bot]
- add a check to verify failedReasons are updated (#7521) by @sapphi-red
- deps: update test262 submodule for tests (#7523) by @sapphi-red
- deps: update taiki-e/install-action action to v2.63.2 (#7496) by @renovate[bot]
- deps: update oxc apps (#7511) by @renovate[bot]
- deps: update oxc to v0.103.0 (#7513) by @camc314
- fix format in `.github/instructions/bug-investigation.instructions.md` (#7506) by @sapphi-red
- add instructions for REPL decoding (#7502) by @sapphi-red
- deps: update github-actions (#7492) by @renovate[bot]
- deps: cargo-shear v1.9.0 (#7483) by @Boshen
- deps: update dependency oxlint-tsgolint to v0.9.0 (#7484) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.8.6 (#7470) by @renovate[bot]
- add syntax validation for test output chunks that are not executed (#7466) by @IWANABETHATGUY
- deps: update dependency rust to v1.92.0 (#7467) by @renovate[bot]
- deps: update test262 submodule for tests (#7457) by @sapphi-red

### ❤️ New Contributors

* @sevenc-nanashi made their first contribution in [#7487](#7487)
* @taearls made their first contribution in [#6890](#6890)

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Missing getLogFilter helper for applying advanced log filters

3 participants