Skip to content

feat(pii): optional IP tracking#72

Merged
samber merged 1 commit into
mainfrom
feat/pii-optional-ip
Jan 6, 2026
Merged

feat(pii): optional IP tracking#72
samber merged 1 commit into
mainfrom
feat/pii-optional-ip

Conversation

@samber
Copy link
Copy Markdown
Owner

@samber samber commented Jan 6, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 6, 2026 16:07
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (3f751eb) to head (6538d35).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
middleware.go 0.00% 21 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main     #72   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          4       4           
  Lines        368     365    -3     
=====================================
+ Misses       368     365    -3     
Flag Coverage Δ
unittests 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samber samber merged commit edf407a into main Jan 6, 2026
17 checks passed
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

This PR introduces optional IP address tracking to the middleware logger, allowing users to control whether client IP addresses (potentially PII) are logged. The implementation adds a new WithClientIP configuration field that defaults to true to maintain backward compatibility with existing behavior.

Key changes:

  • Added WithClientIP boolean field to the Config struct for controlling IP logging
  • Refactored configuration management by extracting a DefaultConfig() function
  • Modified IP logging to be conditional based on the WithClientIP configuration flag

Reviewed changes

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

File Description
middleware.go Added WithClientIP field to Config struct, extracted DefaultConfig() function, made IP logging conditional, and optimized slice pre-allocation
README.md Updated Config struct documentation to include the new WithClientIP field
.github/workflows/test.yml Added fail-fast: false to test matrix configuration

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

Comment thread middleware.go
// DefaultConfig returns the default configuration for the request logger.
func DefaultConfig() Config {
return Config{
DefaultLevel: slog.LevelInfo,
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation. The DefaultLevel field has extra tabs/spaces compared to the other fields in the struct initialization.

Suggested change
DefaultLevel: slog.LevelInfo,
DefaultLevel: slog.LevelInfo,

Copilot uses AI. Check for mistakes.
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The addition of fail-fast: false to the workflow configuration appears unrelated to the PR's purpose of adding optional IP tracking. This change affects CI/CD behavior by allowing all matrix jobs to complete even if one fails. If this is intentional, it should be in a separate PR or explained in the PR description.

Copilot uses AI. Check for mistakes.
Comment thread README.md
WithResponseHeader bool
WithSpanID bool
WithTraceID bool
WithClientIP bool
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The new WithClientIP configuration field is added to the Config struct but lacks documentation explaining its purpose and usage. Given that this is a privacy-related feature (PII tracking), it would be helpful to add a comment or example showing how to disable IP logging for privacy compliance. Consider adding a usage example such as:

config := sloggin.Config{
    WithClientIP: false,  // Disable IP logging for GDPR/privacy compliance
}

Copilot uses AI. Check for mistakes.
Comment thread middleware.go

Filters: []Filter{},
})
return NewWithConfig(logger, Config{})
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

This change breaks backward compatibility. The New() function previously returned a Config with sensible defaults (DefaultLevel: slog.LevelInfo, ClientErrorLevel: slog.LevelWarn, etc.), but now returns an empty Config with zero values. This means:

  1. config.DefaultLevel will be 0 (slog.LevelDebug) instead of slog.LevelInfo
  2. config.ClientErrorLevel and config.ServerErrorLevel will also be 0 instead of their intended values
  3. config.WithRequestID will be false instead of true
  4. config.WithClientIP will be false instead of the new default of true

This breaks existing code using New() and changes the logging behavior in ways users won't expect. The function should return DefaultConfig() instead of an empty Config.

Suggested change
return NewWithConfig(logger, Config{})
return NewWithConfig(logger, DefaultConfig())

Copilot uses AI. Check for mistakes.
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.

2 participants