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

[5.6] LogManager driver capable of producing logger with any Monolog handler #23527

Merged
merged 5 commits into from
Mar 14, 2018

Conversation

ralphschindler
Copy link
Contributor

The provided driver allows a configuration centric approach to creating Logger instances (channels) where the handler can be any of the built-in Monolog handlers without needing to write custom factories (code).

By using Container::build() it is capable of matching any named constructor values from any Handler that are provided in the handler_params configuration option. For non-monolog provided handlers, it is capable of accepting an option handler_class where it will use the full class name to instantiate/build.

Example of creating a php://stderr non-bubbling StreamHandler based logger:

    'channels' => [
        'nonbubblingstream' => [
            'driver' => 'monolog',
            'handler_type' => 'stream',
            'handler_params' => [
                'stream' => 'php://stderr',
                'bubble' => false
            ]
        ],
    //...

Example of a LogEntries based channel logger:

    'channels' => [
        'logentries' => [
            'driver' => 'monolog',
            'handler_type' => 'LogEntries',
            'handler_params' => [
                'token' => '123456789'
            ]
        ],
    //...

This feature is completely backwards compatible and opt-in. If accepted, I will document it's usage in the manual.

@taylorotwell
Copy link
Member

Instead of binding contextual parameters into the container, is it possible to use makeWith?

@ralphschindler
Copy link
Contributor Author

ralphschindler commented Mar 13, 2018

Yes! I didn't realize that make would create instances of arbitrary (non-registered) types. This is much better, it's more clear and concise. (Used make over makeWith since the latter is listed as an alias.)

@taylorotwell taylorotwell merged commit 6fce7fd into laravel:5.6 Mar 14, 2018
@taylorotwell
Copy link
Member

Tweaked things a hair... just went with handler configuration option that must be the class name. Figured people can just use Handler::class and import the handler at the top of the configuration file.

Renamed handler_params to with since it kinda matches the container argument.

Thanks!

@ralphschindler
Copy link
Contributor Author

I dig the changes. 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.

None yet

2 participants