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

Include monolog hander for Log:: facade #204

Closed
pdbreen opened this issue Oct 1, 2016 · 9 comments
Closed

Include monolog hander for Log:: facade #204

pdbreen opened this issue Oct 1, 2016 · 9 comments

Comments

@pdbreen
Copy link

pdbreen commented Oct 1, 2016

Hey @GrahamCampbell - I forked this repo (https://github.com/meadsteve/MonoSnag) to create a v3.4 compatible monolog wrapper (https://github.com/pdbreen/MonoSnag). Then, in AppServiceProvider::boot(), I added the following:

$monolog = \Log::getMonolog();
$bugsnagHandler = new BugsnagHandler(app()['bugsnag'], config('jr.error_level'));
$monolog->pushHandler($bugsnagHandler);

Seems like you might be able to roll this or something similar into your package with an appropriate config setting to set the logger level (or disable).

@GrahamCampbell
Copy link
Contributor

We already support integration with the psr logger, which is the standard. Can I ask why you need monolog please. I'm just trying to understand the use case. :)

@pdbreen
Copy link
Author

pdbreen commented Oct 3, 2016

I've got an existing project that already makes use of the Laravel Log facade. Without the monolog adapter, I couldn't find any way for Bugsnag to report on those errors. Even tried adding a test log route to the laravel sample in the repo with no luck - only the exception test route would report to Bugsnag.

@GrahamCampbell
Copy link
Contributor

Ah, right, yeh. That is a limitation of Laravel where we can't rebind the facade.

@GrahamCampbell
Copy link
Contributor

If you resolve the logger interface from the ioc, that'll work though.

@GrahamCampbell
Copy link
Contributor

Like find and replace Log:: with app('Psr\Log\LoggerInterface')->.

@GrahamCampbell
Copy link
Contributor

I guess the real way we can fix this in laravel's core is to change the facade binding to that interface, then it'll just work.

@pdbreen
Copy link
Author

pdbreen commented Oct 3, 2016

Thanks - I should be able to switch from facade to ioc in this project (and will avoid the facade in future projects). You can feel free to close this (or leave as possible future enhancement). In either case, would be great to add a comment to the docs that the Log:: facade is not supported.

Thanks again

@GrahamCampbell
Copy link
Contributor

This could be fixed in L5.4 if I change the facade to use the psr interface.

@GrahamCampbell
Copy link
Contributor

laravel/framework#15855

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

No branches or pull requests

3 participants