Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@okhoshi
Copy link
Contributor

@okhoshi okhoshi commented Mar 26, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues #53632
License MIT
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 $verbosityLevelMap is 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.

@okhoshi okhoshi force-pushed the monolog-consolehandler-handle-silent branch from 5dff435 to dbd58bc Compare April 1, 2025 15:14
@okhoshi okhoshi requested review from OskarStark and Tobion April 1, 2025 15:15
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Are you suggesting this should be enabled by default, but we don't change it because that'd change the existing behavior?

@okhoshi okhoshi force-pushed the monolog-consolehandler-handle-silent branch from dbd58bc to c34db51 Compare April 8, 2025 14:20
@okhoshi
Copy link
Contributor Author

okhoshi commented Apr 8, 2025

Are you suggesting this should be enabled by default, but we don't change it because that'd change the existing behavior?

The existing behavior is preserved if the new $handleSilent argument is set to true, hence why it's the default value. But it would be more consistent across the different verbosities if it was set to false.

@okhoshi okhoshi requested a review from nicolas-grekas April 22, 2025 07:28
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
@okhoshi okhoshi force-pushed the monolog-consolehandler-handle-silent branch from c34db51 to a827b61 Compare September 2, 2025 09:27
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I'd rather remove the constructor argument and consider this as a bugfix for #53632
/cc @wouterj WDYT?

@okhoshi okhoshi force-pushed the monolog-consolehandler-handle-silent branch 2 times, most recently from cfaf929 to 156f97f Compare September 9, 2025 12:47
@okhoshi okhoshi changed the title [MonologBridge] Add $handleSilent constructor argument to ConsoleHandler [MonologBridge] Make ConsoleHandler not handle messages at SILENT verbosity Sep 9, 2025
@okhoshi okhoshi changed the base branch from 7.4 to 7.3 September 9, 2025 12:48
@carsonbot carsonbot changed the title [MonologBridge] Make ConsoleHandler not handle messages at SILENT verbosity [MonologBridge] Make ConsoleHandler not handle messages at SILENT verbosity Sep 9, 2025
@okhoshi okhoshi force-pushed the monolog-consolehandler-handle-silent branch from 156f97f to c6bed0c Compare September 9, 2025 13:45
@okhoshi okhoshi force-pushed the monolog-consolehandler-handle-silent branch from c6bed0c to c7e655d Compare September 9, 2025 14:16
@nicolas-grekas
Copy link
Member

Thank you @okhoshi.

@nicolas-grekas nicolas-grekas merged commit 91f04e9 into symfony:7.3 Sep 9, 2025
9 of 11 checks passed
@okhoshi okhoshi deleted the monolog-consolehandler-handle-silent branch September 9, 2025 14:30
@wouterj
Copy link
Member

wouterj commented Sep 15, 2025

Oh, this indeed was an oversight. The use-case you're describing makes perfect sense, thanks for sending in the fix!

@fabpot fabpot mentioned this pull request Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants