Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

How to integrate Bugsnag?

Started by Kris Northfield 9 years ago · 2 replies · 1225 views
9 years ago

Any idea how I can tackle this? Would like to integrate our error reporting web service. https://docs.bugsnag.com

They have integrations with plain PHP and Symfony. I'm thinking the pure PHP is best as assume Grav is not a Symphony app although it does use several components.

Any advice would be very welcome, thanks.

9 years ago

Grav uses Monolog, so it's easy to add new error logging capabilities.

I found this handler for Monolog and Bugsnag
https://github.com/meadsteve/MonoSnag

(there are others too).

You should make a small plugin that includes that library using Composer, and adds that to the Grav logger handlers:

PHP
$bugsnagClient = new Bugsnag\Client('YOUR-BUGSNAG-API-KEY-HERE');
$bugsnagHandler = new \MeadSteve\MonoSnag\BugsnagHandler($bugsnagClient);
$this->grav['log']->pushHandler($bugsnagHandler);

(sample code, I didn't try it, but refer to that lib README as well).

Any error should then be sent to Bugsnag as well.

9 years ago

Thanks. I'd got a plugin to send the errors to Bugsnag but the addition of a Monolog handler stopped it from hijacking the existing error handling which was happening in my first attempt.

Suggested topics

Topic Participants Replies Views Activity
General · by ian russell, 4 days ago
2 120 4 days ago
General · by pamtbaau, 1 month ago
2 377 1 week ago
General · by Hanns Mattes, 1 month ago
2 358 2 weeks ago
General · by Andy Miller, 1 month ago
0 260 1 month ago
General · by Jerry Hunt, 1 month ago
2 401 1 month ago