Allow setting levels in Target constructor#128
Merged
Conversation
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #128 +/- ##
=========================================
Coverage 99.55% 99.55%
Complexity 161 161
=========================================
Files 11 11
Lines 448 449 +1
=========================================
+ Hits 446 447 +1
Misses 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Copilot
AI
changed the title
[WIP] Allow setting levels in Target via constructor
Allow setting levels in Target constructor
Dec 5, 2025
Member
|
@copilot add a line for changelog. |
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Contributor
Author
This was referenced Dec 7, 2025
This was referenced Dec 7, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the ability to set log level filtering directly in the Target constructor, simplifying configuration by eliminating the need for a separate setLevels() call after instantiation.
- Adds optional
$levelsparameter toTarget::__construct()and all concrete implementations - Maintains backward compatibility with default empty array accepting all log levels
- Includes comprehensive test coverage for the new feature
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Target.php | Added optional $levels parameter to constructor, calls setLevels() during initialization, improved PHPDoc |
| src/StreamTarget.php | Updated constructor to accept and forward $levels parameter to parent |
| src/PsrTarget.php | Updated constructor to accept and forward $levels parameter to parent |
| tests/TestAsset/DummyTarget.php | Updated test fixture constructor to support $levels parameter |
| tests/TargetTest.php | Added tests verifying level filtering via constructor with both specific levels and empty array |
| tests/StreamTargetTest.php | Added test demonstrating level filtering in StreamTarget constructor |
| tests/PsrTargetTest.php | Added test demonstrating level filtering in PsrTarget constructor |
| CHANGELOG.md | Documented the new feature as entry #128 for version 2.1.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vjik
approved these changes
Dec 9, 2025
Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>
Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>
vjik
approved these changes
Dec 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds optional
$levelsparameter toTarget::__construct()allowing log level filtering to be configured at instantiation rather than requiring a separatesetLevels()call.Changes
array $levels = []parameter$levelsto parentUsage
Before:
After:
Both approaches remain valid. Empty array (default) accepts all levels.
Original prompt
Targetvia constructor #125✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.