Control log creation
You have full control over when and how your requests are logged.
Config file values take precedence over every thing.
Configuration
On a global level you are able to either disable logging completely or black list requests & connectors:
https://github.com/happyDemon/saloon-utils/blob/main/config/saloon-utils.php
Requests
Alternatively, you are able to define logging behaviour on requests individually.
Log only errors
You can limit logging to only errors by implementing the OnlyLogErrorRequest contract.
<?php
use HappyDemon\SaloonUtils\Logger\Contracts\OnlyLogErrorRequest;
use Saloon\Enums\Method;
use Saloon\Http\Request;
class GetServersRequest extends Request implements OnlyLogErrorRequest
{
protected Method $method = Method::GET;
public function resolveEndpoint(): string
{
return '/servers';
}
}Disable logging
You can ensure individual requests will never be recorded by implementing the DoNotLogRequest contract.
Conditional logging
If you want more fine-grained control over which requests should be logged, you can implement the ConditionallyIgnoreLogs contract.
This contract allows you to implement any logic to prevent a request from being logged by returning false.
Last updated