Control log creation

You have full control over when and how your requests are logged.

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.

You are able to add HappyDemon\SaloonUtils\Logger\Contracts\OnlyLogErrorRequest to both Request and Connector classes.

<?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.

You are able to add HappyDemon\SaloonUtils\Logger\Contracts\DoNotLogRequest to both Request and Connector classes.

Conditional logging

If you want more fine-grained control over which requests should be logged, you can implement the ConditionallyIgnoreLogs contract.

You are able to add HappyDemon\SaloonUtils\Logger\Contracts\ConditionallyIgnoreLogs to both Request and Connector classes.

This contract allows you to implement any logic to prevent a request from being logged by returning false.

Last updated