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

Skip to content

[MonologBridge] Add $handleSilent constructor argument to ConsoleHandler #60055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

Okhoshi
Copy link
Contributor

@Okhoshi Okhoshi commented Mar 26, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues None
License MIT

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.

@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 Tobion and OskarStark 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.

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.

6 participants