[MonologBridge] Make ConsoleHandler not handle messages at SILENT verbosity#60055
Merged
nicolas-grekas merged 1 commit intosymfony:7.3from Sep 9, 2025
Merged
Conversation
Tobion
reviewed
Apr 1, 2025
src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
Outdated
Show resolved
Hide resolved
OskarStark
reviewed
Apr 1, 2025
OskarStark
reviewed
Apr 1, 2025
src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
Outdated
Show resolved
Hide resolved
OskarStark
reviewed
Apr 1, 2025
src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
Outdated
Show resolved
Hide resolved
OskarStark
reviewed
Apr 1, 2025
src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
Outdated
Show resolved
Hide resolved
5dff435 to
dbd58bc
Compare
Tobion
approved these changes
Apr 8, 2025
Member
nicolas-grekas
left a comment
There was a problem hiding this comment.
Are you suggesting this should be enabled by default, but we don't change it because that'd change the existing behavior?
dbd58bc to
c34db51
Compare
Contributor
Author
The existing behavior is preserved if the new |
c34db51 to
a827b61
Compare
src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
Outdated
Show resolved
Hide resolved
cfaf929 to
156f97f
Compare
$handleSilent constructor argument to ConsoleHandlerConsoleHandler not handle messages at SILENT verbosity
ConsoleHandler not handle messages at SILENT verbosityConsoleHandler not handle messages at SILENT verbosity
156f97f to
c6bed0c
Compare
…erbosity Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>
c6bed0c to
c7e655d
Compare
nicolas-grekas
approved these changes
Sep 9, 2025
Member
|
Thank you @okhoshi. |
Member
|
Oh, this indeed was an oversight. The use-case you're describing makes perfect sense, thanks for sending in the fix! |
Merged
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.
Original description
Adding a new constructor parameter to ConsoleHandler to let it bubble messages when the output is set at Silent verbosity level (like when using `--silent` in the CLI).
Messages are dropped by the ConsoleHandler down the line because of the verbosity, but they are considered as handled and so bubbling is interrupted if the handler is set with
$bubble = false. The use-case is to have the messages being either printed by the ConsoleHandler (and so seen by the person running the CLI) or sent to the logging system by the next handlers, but not both.Tweaking the
$verbosityLevelMapis not perfect because EMERGENCY level can never be marked as not handled.With this change, the behaviour is more consistent between Silent and Quiet verbosity levels.
Messages are dropped by the ConsoleHandler down the line because of the verbosity, but they are considered as handled and so bubbling is interrupted if the handler is set with
$bubble = false. The use-case is to have the messages being either printed by the ConsoleHandler (and so seen by the person running the CLI) or sent to the logging system by the next handlers, but not both.By not handling messages when the ConsoleHandler verbosity is set to silent, the behaviour is more consistent between, Silent and all the other verbosity levels.