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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

How to integrate Bugsnag?

Started by Kris Northfield 9 years ago · 2 replies · 1145 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 Jerry Hunt, 3 days ago
2 70 5 hours ago
General · by pamtbaau, 10 hours ago
1 45 9 hours ago
General · by Andy Miller, 22 hours ago
0 43 22 hours ago
General · by Marcel, 12 months ago
6 341 4 days ago
General · by Duc , 5 days ago
3 35 5 days ago