tfo / advanced-log
Advanced logging system for Laravel with Slack, Sentry and DataDog integration
Requires
- php: ^8.1
- datadog/dd-trace: ^0.75.0
- laravel/framework: ^10.0|^11.0
- laravel/slack-notification-channel: ^3.0
- sentry/sentry-laravel: ^3.0|^4.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0
- dev-master
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.9
- v1.8.8
- v1.8.7
- v1.8.6
- v1.8.5
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.9
- v1.7.8
- v1.7.7
- v1.7.6
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.9
- v1.6.8
- v1.6.7
- v1.6.6
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2025-05-24 20:20:26 UTC
README
Advanced Logger for Laravel
Advanced logging system for Laravel applications with integrated support for Slack, Sentry, and DataDog (Soon).
Features
- π Simple and intuitive API
- π± Real-time Slack notifications
- π Sentry error tracking integration
- π DataDog metrics support
- π¨ Customizable message formatting
- β‘ Multiple notification channels
- π Secure credentials handling
- π Simplified configuration
Log Destinations
Logs are sent to:
- Local file (storage/logs/laravel.log)
- Slack (via webhook)
- Sentry (if configured)
- DataDog (if configured) SOON
Requirements
- PHP ^8.1
- Laravel ^10.0|^11.0
Installation
You can install the package via composer:
composer require tfo/advanced-log
Configuration
- Publish the configuration file:
php artisan advanced-log:install
The installer will:
Publish configurations Copy loggers to app/Loggers Install ServiceProvider Add .env variables Publish test routes
- Add these variables to your
.env
file:
# Slack Configuration LOGGER_SLACK_WEBHOOK_URL=your-webhook-url LOGGER_SLACK_CHANNEL=#your-channel LOGGER_SLACK_USERNAME=LoggerBot # Sentry Configuration LOGGER_SENTRY_DSN=your-sentry-dsn # DataDog Configuration LOGGER_DATADOG_API_KEY=your-api-key LOGGER_DATADOG_APP_KEY=your-app-key LOGGER_DATADOG_SERVICE=your-service-name # Enable/Disable Services LOGGER_ENABLE_SLACK=true LOGGER_ENABLE_SENTRY=true LOGGER_ENABLE_DATADOG=true
Usage
Log Types and Usage
Test Log Levels Standard Laravel log levels. Use to test basic logging functionality.
Performance Log Monitor execution times and bottlenecks. Use for:
- Long-running processes
- Database queries
- API calls
- Critical user flows
Audit Log Track data changes. Use for:
- User modifications
- Permission changes
- Critical record updates
- Configuration changes
Security Log Monitor security events. Use for:
- Login attempts
- Permission changes
- Suspicious activities
- Access violations
API Log Track API interactions. Use for:
- External service calls
- Endpoint monitoring
- Integration debugging
- API performance
Database Log Monitor database operations. Use for:
- Critical data changes
- Schema updates
- Bulk operations
- Data integrity checks
Job Log Track background tasks. Use for:
- Queue processing
- Scheduled tasks
- Long-running jobs
- Failed job analysis
Cache Log Monitor cache operations. Use for:
- Cache hits/misses
- Cache invalidation
- Memory usage
- Performance optimization
Request Log Track HTTP requests. Use for:
- Important endpoints
- User interactions
- Error tracking
- Performance monitoring
Payment Log Monitor financial transactions. Use for:
- Payment processing
- Refunds
- Subscription changes
- Payment errors
Notification Log Track communication events. Use for:
- Email sending
- SMS delivery
- Push notifications
- Communication errors
File Log Monitor file operations. Use for:
- File uploads
- Downloads
- Storage operations
- File processing
Auth Log Track authentication events. Use for:
- Login/logout
- Password resets
- 2FA events
- Session management
Export Log Monitor data exports. Use for:
- Report generation
- Bulk downloads
- Data migrations
- Export errors
Basic Logging
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']);
Advanced Logging
use Tfo\AdvancedLog\Support\ALog;
Performance Logging
$startTime = microtime(true); // Your code here $duration = (microtime(true) - $startTime) * 1000; ALog::performance('Process Order', $duration, [ 'order_id' => 123 ]);
Audit Logging
ALog::audit('update', 'User', 1, [ 'name' => ['old' => 'John', 'new' => 'Johnny'], 'email' => ['old' => 'john@example.com', 'new' => 'johnny@example.com'] ]);
Security Logging
ALog::security('Login Failed', [ 'email' => 'user@example.com', 'attempts' => 3 ]);
API Logging
$response = response()->json(['status' => 'success']); ALog::api('/api/users', 'GET', $response, 150.5);
Database Logging
ALog::database('create', 'users', 1, [ 'data' => ['name' => 'John', 'email' => 'john@example.com'] ]);
Job Logging
ALog::job('SendWelcomeEmail', 'completed', [ 'user_id' => 1, 'duration' => 1500 ]);
Cache Logging
ALog::cache('hit', 'user:123', [ 'ttl' => 3600 ]);
Request Logging
ALog::request('API Request', [ 'endpoint' => '/api/users', 'params' => ['page' => 1] ]);
Payment Logging
ALog::payment('success', 99.99, 'stripe', [ 'transaction_id' => 'tx_123' ]);
Notification Logging
ALog::notification('email', 'user@example.com', 'welcome', [ 'template' => 'welcome-email' ]);
File Logging
ALog::file('upload', 'images/profile.jpg', [ 'size' => '2.5MB', 'type' => 'image/jpeg' ]);
Auth Logging
ALog::auth('login_success', [ 'remember' => true, 'device' => 'iPhone 13' ]);
Export Logging
ALog::export('users', 1000, [ 'format' => 'csv', 'filters' => ['status' => 'active'] ]);
Channels
Slack
Messages are sent to Slack with:
- Emojis indicating log level
- Color-coded messages
- Structured context fields
- Custom channel support
Sentry
Errors are tracked in Sentry with:
- Full stack traces
- Environment information
- User context
- Custom tags and breadcrumbs
DataDog
Metrics are sent to DataDog with:
- Custom metrics
- Tagging
- Event aggregation
- Performance tracking
Testing
composer test
Changelog
See CHANGELOG.md for more information about recent changes.
Contributing
See CONTRIBUTING.md for details.
Security
If you discover any security-related issues, please email thallesfreitas@yahoo.com.br instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.