sinarajabpour1998/log-manager
Laravel log manager with UI components and migrations to store custom activity logs and system error logs in database tables. Define log types in config, use LogFacade to generate logs, and hook into Exception Handler to capture errors.
Architecture fit
The log-manager package is a lightweight, domain-specific extension for Laravel, leveraging its MVC architecture and facade pattern. It introduces two core tables (logs, error_logs) and a Blade component (<x-log-menu>) for UI integration, aligning with Laravel’s conventions (e.g., migrations, service providers, facades). The package’s modular design (log types, error handling, and UI) allows for selective adoption without forcing monolithic changes. However, its tight coupling to Laravel’s Blade and database layers limits portability to non-Laravel PHP stacks.
Integration feasibility
config/log-manager.php, enabling tailored use cases (e.g., audit trails, SMS logs).BaseFacade bug fix suggests prior instability.Technical risk
BaseFacade not found error (v1.2.3) indicates potential namespace or service provider misconfigurations. Validate facade binding in config/app.php or the package’s service provider.error_trace, which may expose sensitive stack traces. Ensure error_logs table permissions are restricted (e.g., via Laravel’s can gates).<x-log-menu> assumes Laravel’s Blade compiler. Custom views may require adjustments for theming or localization.logs/error_logs tables. Plan for manual pruning or use Laravel’s schedule:run with a custom job.LogFacade::class resolves correctly in a fresh Laravel install.whereRaw in older Laravel versions).Key questions
spatie/laravel-log-viewer or laravel-debugbar for feature parity.)single or stack channels instead of the database?)error_trace field sanitized? (Avoid exposing raw stack traces in production.)Stack fit
LogFacade and LogErrorFacade for fluent syntax.<x-log-menu> component for UI integration.php artisan migrate.App\Exceptions\Handler.php.Migration path
logs table.App\Exceptions\Handler.php for existing error logging logic.composer require sinarajabpour1998/log-manager
php artisan vendor:publish --tag=log-manager
php artisan migrate
log_types in config/log-manager.php.App\Exceptions\Handler.php to include LogFacade::generateErrorLog($e).<x-log-menu> to sidebar/layout Blade files.LogFacade::generateLog("type") with a custom log type.Compatibility
| Component | Laravel 8.x | Laravel 9.x | Laravel 10.x | Laravel 11.x |
|---|---|---|---|---|
| Facade resolution | ✅ | ✅ | ✅ | ✅ |
| Blade components | ✅ | ✅ | ✅ | ✅ |
| Migrations | ✅ | ✅ | ⚠️* | ⚠️* |
| Error handling | ✅ | ✅ | ✅ | ✅ |
⚠️ Note: Laravel 10+ may require adjustments for new Eloquent query builder methods or migration syntax.
Sequencing
LogFacade::throttle(60)).Maintenance
BaseFacade breaks again).php artisan package:discover to verify the package loads.// tests/Feature/LogFacadeTest.php
public function test_facade_resolves()
{
$this->assertTrue(class_exists(\Sinarajabpour1998\LogManager\Facades\LogFacade::class));
}
Facade or Blade components, the package may need rewrites.Support
php artisan optimize:clear).created_at conflicts).log_types are defined before use./vendor/) in error_trace.Scaling
LogFacade::generateLog() triggers a DB insert. High-volume apps may need:
log_type and created_at.<x-log-menu> component fetches logs via Blade. Add pagination or lazy-loading:
// Example: Paginated logs in a custom controller
$logs = \Sinarajabpour1998\LogManager\Models\Log::paginate(20);
Failure modes
| Scenario | Impact | Mitigation |
|---|---|---|
| Facade resolution fails | Logs/errors silently fail | Add try-catch around facade calls. |
| Database connection drops | Logs lost during outages | Implement retry logic or queue jobs. |
| Blade component rendering errors | UI breaks | Fallback to a static link. |
| Log table grows uncontrollably | DB performance degrades | Set up a cron job to archive old logs. |
| Laravel version incompatibility | Package breaks | Fork and maintain locally. |
Ramp-up
How can I help you explore Laravel packages today?