Download the PHP package bit-mx/saloon-logger-plug-in without Composer
On this page you can find all versions of the php package bit-mx/saloon-logger-plug-in. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package saloon-logger-plug-in
Saloon Logger Plug-in
A Laravel plug-in for the Saloon HTTP client Saloon v4 that provides automatic observability and traceability for all HTTP interactions made with the Saloon library.
This package transparently logs requests, responses and exceptions to the database, and links all events using a single trace_id (ULID).
Features
- Traceability: Generates a unique identifier to tie the request, response and any exception together.
- Transparent integration: Enable logging simply by applying traits to the connector and request classes.
- Data sanitization: Automatically censors sensitive fields (for example passwords or authentication tokens) in logged payloads and headers.
- Reliable storage: Uses a dedicated database table for structured storage of logs.
Installation
Requirements
Install via Composer
Install the package using Composer:
composer require bit-mx/saloon-logger-plug-in
Publish and run migrations
This command will publish the migration into your database/migrations directory:
php artisan vendor:publish --tag=saloon-logger-migrations
Then run the migrations:
php artisan migrate
Publish configuration (optional)
You can publish the configuration file to customize which fields are censored:
php artisan vendor:publish --tag=saloon-logger-config
This will create config/saloon-logger.php.
Usage
Step 1: Apply the Traits
To enable traceability, add the HasLogging trait to your connector and the ProvidesDefaultBody trait to your request.
Connector example:
Request example:
Step 2: Send the Request
Whenever a request is sent through this connector, the package will automatically log the events to the database table.
If an HTTP or network exception occurs (for example a 500), the package will log the request and the exception.
Other languages
Spanish
Custom sanitizers
If you need a custom way to sanitize payloads or headers before they are stored, implement the SanitizerRequestContract and register your class in the package configuration under the sanitizers.request array.
Example request custom sanitizer:
If you need a custom way to sanitize the response before they are stored, implement the SanitizerResponseContract and register your class in the package configuration under the sanitizers.response array.
Example Response custom sanitizer:
Then register it in config/saloon-logger.php:
Sanitizers are applied in the order they appear in the configuration. Each sanitizer receives the data and must return the updated value.
Prune & Backup
You can configure the package to prune old records and make a backup of the records. The options are available separately in the configuration file
All versions of saloon-logger-plug-in with dependencies
laravel/framework Version ^12.39|^13.0
saloonphp/saloon Version ^4.0
saloonphp/laravel-plugin Version ^4.0