Implement structured logging with redaction support.#1
Conversation
…ing implementation.
…action strategies for documents, emails, and phone numbers.
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bf9218749
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This pull request implements a structured logging library with support for sensitive data redaction and correlation tracking. The implementation is built on top of PSR-3's LoggerInterface and provides a fluent builder API for configuring loggers with optional data redaction strategies.
Changes:
- Implements a PSR-3 compliant structured logger with support for correlation IDs and customizable output templates
- Adds three built-in redaction strategies (document, email, phone) with configurable masking behavior
- Provides comprehensive test coverage with 749 lines of PHPUnit tests covering various logging scenarios and edge cases
Reviewed changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/StructuredLogger.php | Core logger implementation with PSR-3 LoggerTrait and immutable context support |
| src/StructuredLoggerBuilder.php | Fluent builder for configuring logger instances with streams, components, templates, and redactions |
| src/Logger.php | Interface extending PSR-3 LoggerInterface with withContext method for immutable context propagation |
| src/LogContext.php | Value object representing correlation ID context |
| src/LogLevel.php | Enum defining all PSR-3 log levels |
| src/Redaction.php | Interface for implementing custom redaction strategies |
| src/Redactions/DocumentRedaction.php | Redaction strategy for masking document fields (e.g., CPF, CNPJ) |
| src/Redactions/EmailRedaction.php | Redaction strategy for masking email addresses while preserving domain |
| src/Redactions/PhoneRedaction.php | Redaction strategy for masking phone numbers |
| src/Internal/LogFormatter.php | Formats log entries using sprintf templates with timestamp, component, level, and JSON data |
| src/Internal/Stream/LogStream.php | Wrapper for stream resources with write capability |
| src/Internal/Redactor/Redactor.php | Generic redactor applying masking functions to specified fields recursively |
| src/Internal/Redactor/Redactions.php | Collection of redaction instances with applyTo method |
| tests/StructuredLoggerTest.php | Comprehensive test suite with 749 lines covering logging, redaction, and edge cases |
| composer.json | Package definition with PHP 8.5 requirement and dependencies |
| README.md | Complete documentation with usage examples and API reference |
| phpunit.xml | PHPUnit configuration with coverage reporting |
| phpstan.neon.dist | PHPStan static analysis configuration at level 9 |
| infection.json.dist | Infection mutation testing configuration |
| Makefile | Development workflow automation for testing and review |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.