How do breadcrumbs help?
A big part of debugging errors is wondering, "How did this happen? Why is this value null?" To help with this, you've probably added extra logs to your app, so you can reference them when something happens.
Log::debug("Processed payment request for $userId"); Log::debug("Sending notification to user $userId on channel $channel");
But logs can be noisy and unstructured. Breadcrumbs let you replace those debug logs with structured event records. No more scouring log files to find out what was going on at 11:20 PM yesterday. Record these events with Honeybadger and you'll see the breadcrumbs right in the error detail on your dashboard.
Recording a breadcrumb is easy. Use the
addBreadcrumb() method on the Honeybadger client:
$honeybadger->addBreadcrumb('Sending notification', ['user' => $user->id, 'channel' => $channel]); // In Laravel Honeybadger::addBreadcrumb('Sending notification', ['user' => $user->id, 'channel' => $channel]);
If an error occurs later, the breadcrumb will show up in your dashboard:
In our example, the
channel is empty — that might be the cause of our error.
Automatic Breadcrumbs in Laravel
Even better, if you're using Laravel, we'll automatically capture breadcrumbs for interesting events. We listen for the following events:
- Log messages
- View renders
- Email dispatches
- Job dispatches
- Notification dispatches
- Database queries
- Redis commands
- Incoming requests
All of this can be configured in the
config/honeybadger.php config file.
How can you use them?
Breadcrumbs are currently available in our PHP client as of version 2.8.0, and in our Laravel client as of version 3.8.0. You can update your Honeybadger client by running:
composer update honeybadger-io/honeybadger-laravel
composer update honeybadger-io/honeybadger-php
(depending on which you're using.)
Be sure to check out our documentation for more details on using breadcrumbs in PHP.
Let us know how it goes!
We hope that breadcrumbs will be a helpful addition to your debugging toolbox. Try it out, and give us a shout if there is anything you would like to see added.