Breadcrumbs
Breadcrumbs are additional information you can add to any type of event.
The Streply/Breadcrumb
method consists of 3 parameters:
function Breadcrumb( string $type, string $message, array $params = [] ): void
(string) $type
- Type of crumb(string) $message
- Crumb content(array) $params
- Parameters
Available crumb types:
Streply\Enum\BreadcrumbType::INFO
Streply\Enum\BreadcrumbType::DEBUG
Streply\Enum\BreadcrumbType::ERROR
Streply\Enum\BreadcrumbType::QUERY
Crumbs are not a separate event type but additional information sent to a previously sent event. For example, suppose we send a log when exporting users. In addition, we want to measure the time of each step in our code. We can use crumbs for this.
<?php use Streply\Enum\BreadcrumbType; Streply\Log('users.export'); Streply\Breadcrumb(BreadcrumbType::INFO, 'get users from database'); Streply\Breadcrumb(BreadcrumbType::QUERY, $query); ... Streply\Breadcrumb(BreadcrumbType::INFO, 'remove wrong emails'); ... if(true === $error) { Streply\Breadcrumb(BreadcrumbType::DEBUG, $errorMessage, [ 'isExternalUser' => true ]); } ... Streply\Breadcrumb(BreadcrumbType::INFO, 'create excel file'); ... Streply\Breadcrumb(BreadcrumbType::INFO, 'download');
Thanks to the breadcrumbs, we will have information in the users.export
log with loading times for the individual application stages that are important to us.
Package
streply/streply-php
Repository
https://github.com/streply/streply-php