bilfeldt / laravel-http-client-logger

A logger for the Laravel HTTP Client
MIT License
144 stars 19 forks source link

Add new on-demand configuration #6

Closed bilfeldt closed 3 years ago

bilfeldt commented 3 years ago

This PR adds an extra $config parameter to HttpLoggerInterface, HttpLoggingFilterInterface and the two macros log and logWhen.

The purpose of this PR is to make it possible to specify configuration on demand.

Example

The default configuration is to log only request/responses with errors

// config/http-client-logger.php
'filtering' => [
    'always' => false,
    '2xx' => false,
    '3xx' => false,
    '4xx' => true,
    '5xx' => true
],

with this PR is now possible to log just one request/response to say a specific disk:

$config = [
    'filtering' => [
        'always' => true,
    ],
    'log_to_disk' => [
        'enabled' => true,
        'disk' => 'local',
    ],
];
Http::log([], $config)->get(....);