Skip to content
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

[8.x] support action_level configuration #40305

Merged
merged 3 commits into from
Jan 7, 2022
Merged

[8.x] support action_level configuration #40305

merged 3 commits into from
Jan 7, 2022

Conversation

wimulkeman
Copy link
Contributor

Adding an action_level configuration option for log channels. When the action_level configuration is used the chosen handler by the developer will be wrapped in a Fingerscrossed handler.

The Fingerscrossed handler will buffer all log records that are at or above the provided level configuration. Only when a log record is provided at or above the action_level all the buffered records will be flushed to the log itself.

This methodology can be usefull for a developer to gather debug information about a process while only logging that debug information if the code actually hits a critical error.

An example of the usage of the action_level configuration can be found in the Symfony documentation about logging using Monolog.

Wim Ulkeman and others added 3 commits January 7, 2022 19:32
Enable the usage of the action_level configuration for log channels. When the action_level configuration is used the choosen handler by the developer will be wrapped in a Fingerscrossed handler.

The Fingerscrossed handler will buffer all log records that are at or above the provided level configuration. Only when a log record is provided at or above the action_level all the buffered records will be flushed to the log itself.

This methodology helps developers to gather debug information about a process while only logging that debug information if the code hits for example a critical error.

@see https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/FingersCrossedHandler.php
@see https://symfony.com/doc/current/logging.html#handlers-that-modify-log-entries
Support checking the wrapped handler in older Monolog versions (pre 1.x). In the older versions the getHandler method was not yet available. The handler was only set as a protected property.
@taylorotwell taylorotwell merged commit bed54df into laravel:8.x Jan 7, 2022
@taylorotwell taylorotwell deleted the add_action_level_support_to_logging branch January 7, 2022 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants