PHP code example of ermetix / laravel-logger
1. Go to this page and download the library: Download ermetix/laravel-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/ */
ermetix / laravel-logger example snippets
use Ermetix\LaravelLogger\Facades\LaravelLogger as Log;
use Ermetix\LaravelLogger\Support\Logging\Objects\GeneralLogObject;
// Deferred logging (non-blocking, default)
Log::general(new GeneralLogObject(
message: 'user_profile_updated',
event: 'profile_updated',
entityType: 'user',
entityId: '123',
userId: '456',
level: 'info',
));
// Immediate logging (blocking)
Log::general(new GeneralLogObject(
message: 'critical_event',
event: 'payment_processed',
level: 'info',
), defer: false);
use Ermetix\LaravelLogger\Facades\LaravelLogger as Log;
use Ermetix\LaravelLogger\Support\Logging\Objects\IntegrationLogObject;
Log::integration(new IntegrationLogObject(
message: 'external_api_call',
integrationName: 'stripe',
url: 'https://api.stripe.com/v1/charges',
method: 'POST',
status: 200,
durationMs: 350,
requestBody: json_encode(['amount' => 1000]),
responseBody: json_encode(['id' => 'ch_123']),
));
use Ermetix\LaravelLogger\Facades\LaravelLogger as Log;
use Ermetix\LaravelLogger\Support\Logging\Objects\JobLogObject;
Log::job(new JobLogObject(
message: 'custom_job_event',
job: 'MyCustomJob',
status: 'success',
durationMs: 1500,
frequency: null,
output: 'Custom output message',
));
Log::general(new GeneralLogObject(
message: 'test_log',
level: 'info',
));
bash
# 1. Install the package
composer artisan laravel-logger:install
# 3. Verify installation
php artisan laravel-logger:verify
bash
php artisan laravel-logger:install
bash
php artisan laravel-logger:install --force
bash
php artisan laravel-logger:verify
bash
php packages/laravel-logger/docker/opensearch/setup.php --with-dashboards
bash
php packages/laravel-logger/docker/opensearch/setup.php
bash
# On macOS with Homebrew
pecl install pcov
# On Linux
sudo pecl install pcov
# Enable in php.ini
echo "extension=pcov.so" >> php.ini
echo "pcov.enabled=1" >> php.ini
bash
# On macOS with Homebrew
pecl install xdebug
# On Linux
sudo pecl install xdebug
# Enable in php.ini
echo "zend_extension=xdebug.so" >> php.ini
echo "xdebug.mode=coverage" >> php.ini
bash
php artisan laravel-logger:verify