PHP code example of kssadi / log-tracker
1. Go to this page and download the library: Download kssadi/log-tracker 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/ */
kssadi / log-tracker example snippets
return [
/*
|--------------------------------------------------------------------------
| Route Configuration
|--------------------------------------------------------------------------
*/
'route_prefix' => 'log-tracker',
'middleware' => ['web', 'auth'],
/*
|--------------------------------------------------------------------------
| Theme Selection
|--------------------------------------------------------------------------
*/
'theme' => 'GlowStack', // Options: 'LiteFlow', 'GlowStack'
/*
|--------------------------------------------------------------------------
| Display Settings
|--------------------------------------------------------------------------
*/
'log_per_page' => 50,
'log_files_per_page' => 10,
'max_file_size' => 50, // MB
/*
|--------------------------------------------------------------------------
| Feature Permissions
|--------------------------------------------------------------------------
*/
'allow_delete' => true,
'allow_download' => true,
/*
|--------------------------------------------------------------------------
| Export Configuration
|--------------------------------------------------------------------------
*/
'export' => [
'enabled' => true,
'formats' => [
'csv' => [
'enabled' => true,
'description' => 'Excel-compatible CSV format'
],
'json' => [
'enabled' => true,
'description' => 'Structured JSON with metadata'
],
'excel' => [
'enabled' => true,
'description' => 'Native Excel XML format'
],
'pdf' => [
'enabled' => true,
'description' => 'Print-ready HTML report'
],
],
'limits' => [
'max_entries' => 50000,
'max_file_size_mb' => 50,
'timeout_seconds' => 300,
],
'storage' => [
'cleanup_after_days' => 7,
],
],
];
LOG_CHANNEL=daily # Recommended for structured logging
LOG_LEVEL=debug # Set the minimum log level to be recorded
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 30, // Keep logs for the last 30 days
],
use Illuminate\Support\Facades\Log;
// Basic log levels
Log::info('User logged in successfully', ['user_id' => 123]);
Log::warning('Disk space is running low', ['disk_usage' => '85%']);
Log::error('Payment processing failed', ['order_id' => 'ORD-12345', 'error' => 'Gateway timeout']);
// Emergency and Critical logs
Log::emergency('Database connection lost completely');
Log::critical('Memory limit exceeded', ['memory_usage' => '512MB']);
Log::alert('Security breach detected', ['ip_address' => '192.168.1.100']);
// Debug and Notice logs
Log::debug('API response received', ['response_time' => '250ms', 'endpoint' => '/api/users']);
Log::notice('User password changed', ['user_id' => 456]);
// Logs with context data
Log::error('File upload failed', [
'file_name' => 'document.pdf',
'file_size' => '5MB',
'user_id' => 789,
'error_code' => 'UPLOAD_TIMEOUT'
]);
// Exception logging
try {
// Some risky operation
throw new \Exception('Sample exception for testing');
} catch (\Exception $e) {
Log::error('Exception caught: ' . $e->getMessage(), [
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString()
]);
}
'theme' => 'GlowStack', // Options: 'LiteFlow', 'GlowStack'
'export' => [
'enabled' => true,
'formats' => [
'csv' => [
'enabled' => true,
'description' => 'Excel-compatible CSV format'
],
'json' => [
'enabled' => true,
'description' => 'Structured JSON with metadata'
],
'excel' => [
'enabled' => true,
'description' => 'Native Excel XML format'
],
'pdf' => [
'enabled' => true,
'description' => 'Print-ready HTML report'
],
],
'limits' => [
'max_entries' => 50000, // Maximum records per export
'max_file_size_mb' => 50, // Max file size for processing
'timeout_seconds' => 300, // Export timeout
],
'storage' => [
'cleanup_after_days' => 7, // Auto-cleanup exported files
],
],
// Dashboard
GET /log-tracker
// Log file list
GET /log-tracker/log-file
// View specific log file
GET /log-tracker/{logName}
// Download log file
GET /log-tracker/download/{logName}
// Export log file
POST /log-tracker/export/{logName}
// Delete log file (if enabled)
POST /log-tracker/delete/{logName}
'middleware' => ['web', 'auth'],