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

Add support for configurable wrapped handlers #49

Merged
merged 2 commits into from
Feb 18, 2016
Merged

Add support for configurable wrapped handlers #49

merged 2 commits into from
Feb 18, 2016

Conversation

michaelmoussa
Copy link
Contributor

This pull request adds support for using Monolog's Special / Wrapped Handlers with configuration alone. Let's take, for example, the GroupHandler and FingersCrossedHandler.

GroupHandler lets you group several other handlers together, and FingersCrossedHandler accumulates log messages until severity exceeds a particular log level. In my case, I want to record all of my messages once the CRITICAL threshold is reached, and I want them to go to a file and to Slack. After this PR, I can do something like this:

handlers:
    file:
        class: Monolog\Handler\StreamHandler
        level: DEBUG
        stream: /path/to/file.log
    slack:
        class: Monolog\Handler\SlackHandler
        ... various slack config goes here ...
    group:
        class: Monolog\Handler\GroupHandler
        handlers: [file, slack]
    fingers_crossed:
        class: Monolog\Handler\FingersCrossedHandler
        handler: group
loggers:
    myLogger:
        handlers: [fingers_crossed]

It will replace the [file, slack] array in handlers.group.handlers with the actual file and slack handlers, and the group entry in handlers.fingers_crossed.handler with the actual group handler.

PR includes tests, and I don't see any BC issues stemming from this.

@rantonmattei
Copy link
Contributor

LGTM
Thanks!

rantonmattei added a commit that referenced this pull request Feb 18, 2016
Add support for configurable wrapped handlers
@rantonmattei rantonmattei merged commit 4d78f9c into theorchard:master Feb 18, 2016
@michaelmoussa michaelmoussa deleted the wrapped-handlers branch February 19, 2016 03:22
@michaelmoussa
Copy link
Contributor Author

@rantonmattei Thanks! Would you mind tagging a release with these new changes soon?

@rantonmattei
Copy link
Contributor

@michaelmoussa ,0.4.0 is out!

@michaelmoussa
Copy link
Contributor Author

👍 thanks!

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