1. Go to this page and download the library: Download shipsaas/shipsaas-logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shipsaas / shipsaas-logger example snippets
'shipsaas-logger' => [
'driver' => 'shipsaas-logger',
'path' => storage_path('logs/requests/laravel.log'), // can change to your desired path
'default_log_file' => storage_path('logs/laravel.log'), // can change to your desired path
'id-type' => 'ulid', // uuid, orderedUuid, ulid
'use_json_format' => false, // set to true to write log as JSON
],
class TransferController extends BaseController
{
public function transfer(): JsonResponse
{
Log::info('begin transfer', [
'amount' => ...,
'recipient' => ...,
]); // this log will have uniqueRequestId
// ...
Log::info('transferred', [
'amount' => ...,
'recipient' => ...,
'trasaction_id' => ...,
]); // this log will have uniqueRequestId
}
}
// AppServiceProvider.php
use ShipSaasUniqueRequestLogger\UniqueRequestIdLoggerInitiator;
public function boot(): void
{
$this->app->booted(fn () => UniqueRequestIdLoggerInitiator::init());
}
dotenv
LOG_CHANNEL=shipsaas-logger
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.