bilfeldt / laravel-http-client-logger

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

Filtering data based on keys not values #12

Open bilfeldt opened 2 years ago

bilfeldt commented 2 years ago

It should be possible to provide an array of headers to filter, an array of query parameters to filter and body parameters to remove (last two could be combined to one payload array) - note that this can be individual for request and response:

Http::log([], // No context added
    [
        'filter_request_headers' => [
            'user-agent',
        ],
        'filter_request_payload' => [
            'apitoken', // remove any "apitoken" provided in either request json or query
        ],
        'filter_response_payload' => [
            'data.*.base64_pdf',
        ],
    ]
)->get(...)
bilfeldt commented 2 years ago

I suggest using a dedicated logger using logWith and the new MessageAccessor that were both introduced in v1.1.0 - see #13 and #15