PHP code example of tfo / advanced-log
1. Go to this page and download the library: Download tfo/advanced-log 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/ */
tfo / advanced-log example snippets
use Illuminate\Support\Facades\Log;
Log::emergency('Emergency log test', ['context' => 'test']);
Log::alert('Alert log test', ['context' => 'test']);
Log::critical('Critical log test', ['context' => 'test']);
Log::error('Error log test', ['context' => 'test']);
Log::warning('Warning log test', ['context' => 'test']);
Log::notice('Notice log test', ['context' => 'test']);
Log::info('Info log test', ['context' => 'test']);
Log::debug('Debug log test', ['context' => 'test']);
use Tfo\AdvancedLog\Support\ALog;
$startTime = microtime(true);
// Your code here
$duration = (microtime(true) - $startTime) * 1000;
ALog::performance('Process Order', $duration, [
'order_id' => 123
]);
ALog::audit('update', 'User', 1, [
'name' => ['old' => 'John', 'new' => 'Johnny'],
'email' => ['old' => '[email protected] ', 'new' => '[email protected] ']
]);
ALog::security('Login Failed', [
'email' => '[email protected] ',
'attempts' => 3
]);
$response = response()->json(['status' => 'success']);
ALog::api('/api/users', 'GET', $response, 150.5);
ALog::database('create', 'users', 1, [
'data' => ['name' => 'John', 'email' => '[email protected] ']
]);
ALog::job('SendWelcomeEmail', 'completed', [
'user_id' => 1,
'duration' => 1500
]);
ALog::cache('hit', 'user:123', [
'ttl' => 3600
]);
ALog::request('API Request', [
'endpoint' => '/api/users',
'params' => ['page' => 1]
]);
ALog::payment('success', 99.99, 'stripe', [
'transaction_id' => 'tx_123'
]);
ALog::notification('email', '[email protected] ', 'welcome', [
'template' => 'welcome-email'
]);
ALog::file('upload', 'images/profile.jpg', [
'size' => '2.5MB',
'type' => 'image/jpeg'
]);
ALog::auth('login_success', [
'remember' => true,
'device' => 'iPhone 13'
]);
ALog::export('users', 1000, [
'format' => 'csv',
'filters' => ['status' => 'active']
]);
bash
php artisan advanced-log:install