Skip to content

feat(logging): add LOG_FILTER for access log noise reduction#295

Merged
polaz merged 11 commits intomainfrom
feat/#290-featlogging-add-logskiprequests-filter-for-access
Feb 5, 2026
Merged

feat(logging): add LOG_FILTER for access log noise reduction#295
polaz merged 11 commits intomainfrom
feat/#290-featlogging-add-logskiprequests-filter-for-access

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Feb 5, 2026

Summary

  • Add LOG_FILTER environment variable to filter requests from access logs
  • Default filters Claude Code polling (GET / with claude-code user agent)
  • Support method, path (exact or prefix with *), and userAgent matching
  • Set LOG_FILTER='[]' to log all requests

Changes

  • src/config.ts: Zod schema, parsing, shouldSkipAccessLog() function
  • src/server.ts: Apply filter in access log middleware
  • docs/guide/configuration.md: Documentation with examples
  • .env.example: Configuration reference
  • tests/unit/config.test.ts: 24 new tests for filter logic

Test plan

  • yarn lint passes
  • yarn test tests/unit/config.test.ts — 106 tests pass
  • Manual test: start server, verify Claude Code polling not logged

Closes #290

- Add LOG_FILTER environment variable to filter requests from access logs
- Default filters Claude Code polling (GET / with claude-code user agent)
- Support method, path (exact or prefix with *), and userAgent matching
- Set LOG_FILTER='[]' to log all requests
- Add Zod schema validation with startup warning for invalid JSON
- Log active filter count at startup

Closes #290
Copilot AI review requested due to automatic review settings February 5, 2026 02:08
polaz added 2 commits February 5, 2026 04:08
- Add LOG_FILTER and shouldSkipAccessLogRequest to all jest.doMock
  calls that override the config module
- Fixes test failures caused by missing mock values after jest.resetModules
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 5, 2026

Test Coverage Report

Overall Coverage: 95.77%

Metric Percentage
Statements 95.24%
Branches 86.12%
Functions 94.35%
Lines 95.77%

View detailed coverage report

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 92.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/config.ts 93.33% 1 Missing and 2 partials ⚠️
src/server.ts 80.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

- Add test for logInfo call when LOG_FILTER has rules
- Add test verifying access logging middleware skips requests
  matching shouldSkipAccessLogRequest filter
@polaz polaz review requested due to automatic review settings February 5, 2026 02:27
Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

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

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

- Changed em-dash (—) to "Claude Code filter" for consistency
  with the summary table at the top of the Logging section
Copy link
Copy Markdown

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

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

- /health endpoint is registered BEFORE access logging middleware
- Requests to /health never go through access logging
- Removed examples suggesting to filter /health (unnecessary)
- Added note explaining /health is not logged
Copy link
Copy Markdown

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

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

- Added expect(console.warn).toHaveBeenCalled() to invalid schema test
- Matches pattern used in invalid JSON test (lines 991-1004)
Copy link
Copy Markdown

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

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

polaz added 2 commits February 5, 2026 04:59
- Added LOG_FORMAT: "condensed" to main jest.mock and all jest.doMock
  calls for config module consistency
…prequests-filter-for-access' into feat/#290-featlogging-add-logskiprequests-filter-for-access
Copy link
Copy Markdown

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

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

- Whitespace-only LOG_FILTER now falls back to default filter
  instead of disabling all filtering (empty array)
- Add unit test for shouldSkipAccessLogRequest with Express Request
Copy link
Copy Markdown

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

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

@polaz polaz merged commit d0c3d0d into main Feb 5, 2026
23 checks passed
@polaz polaz deleted the feat/#290-featlogging-add-logskiprequests-filter-for-access branch February 5, 2026 03:16
sw-release-bot bot pushed a commit that referenced this pull request Feb 5, 2026
## [6.58.0](v6.57.0...v6.58.0) (2026-02-05)

### Features

* **logging:** add LOG_FILTER for access log noise reduction ([#295](#295)) ([d0c3d0d](d0c3d0d)), closes [#290](#290)
sw-release-bot bot pushed a commit that referenced this pull request Feb 5, 2026
## [6.58.0](v6.57.0...v6.58.0) (2026-02-05)

### Features

* **logging:** add LOG_FILTER for access log noise reduction ([#295](#295)) ([d0c3d0d](d0c3d0d)), closes [#290](#290)

### Bug Fixes

* **ci:** configure git credentials for semantic-release tag upload ([#298](#298)) ([6563291](6563291)), closes [#297](#297)
* **ci:** remove duplicate Authorization header, add token scope ([#300](#300)) ([4032584](4032584)), closes [#299](#299)
@sw-release-bot
Copy link
Copy Markdown

sw-release-bot bot commented Feb 5, 2026

🎉 This PR is included in version 6.58.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(logging): add LOG_FILTER for access log noise reduction

2 participants