Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Log Manager Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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

  • Low effort: Installation requires only Composer, a migration, and Blade component registration—standard Laravel workflows.
  • Dependencies: No external services or complex setups; relies solely on Laravel’s built-in logging and database systems.
  • Customization: Log types and permissions are configurable via config/log-manager.php, enabling tailored use cases (e.g., audit trails, SMS logs).
  • Risk: The package’s abandoned status (last release 2021) and lack of dependents raise concerns about long-term maintenance. The BaseFacade bug fix suggests prior instability.

Technical risk

  • Critical:
    • Facade resolution: The 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.
    • Database schema: No schema migrations are versioned or documented beyond the initial release. Future Laravel versions may introduce breaking changes (e.g., query builder deprecations).
    • Security: Error logs store error_trace, which may expose sensitive stack traces. Ensure error_logs table permissions are restricted (e.g., via Laravel’s can gates).
  • Moderate:
    • Blade component: The <x-log-menu> assumes Laravel’s Blade compiler. Custom views may require adjustments for theming or localization.
    • Log retention: No built-in cleanup mechanism for the logs/error_logs tables. Plan for manual pruning or use Laravel’s schedule:run with a custom job.
  • Mitigation:
    • Test facade instantiation: Verify LogFacade::class resolves correctly in a fresh Laravel install.
    • Audit database queries: Check for deprecated Eloquent methods (e.g., whereRaw in older Laravel versions).
    • Backup tables: Before migration, export existing logs to avoid data loss.

Key questions

  1. Why was the package abandoned? (Check GitHub issues/PRs for unresolved bugs or lack of adoption.)
  2. Are there alternatives? (Compare with spatie/laravel-log-viewer or laravel-debugbar for feature parity.)
  3. How are log types managed? (Is there a dynamic way to add types without config file edits? E.g., via migrations or seeders.)
  4. What’s the error log retention policy? (No TTL or soft-deletes mean tables could bloat over time.)
  5. Does the package support Laravel’s logging channels? (E.g., could logs be written to single or stack channels instead of the database?)
  6. Is the error_trace field sanitized? (Avoid exposing raw stack traces in production.)

Integration Approach

Stack fit

  • Laravel-specific: Fully compatible with Laravel 8–11, leveraging:
    • Facades: LogFacade and LogErrorFacade for fluent syntax.
    • Blade: <x-log-menu> component for UI integration.
    • Migrations: Database schema via php artisan migrate.
    • Exceptions: Hooks into App\Exceptions\Handler.php.
  • Non-Laravel PHP: Not applicable. The package relies on Laravel’s service container, Blade, and Eloquent.
  • Stack conflicts:
    • Database: Assumes MySQL/PostgreSQL (no SQLite-specific optimizations).
    • Caching: No cache layer for log queries; performance may degrade with large log volumes.

Migration path

  1. Pre-integration:
    • Backup: Dump existing logs (if any) from logs table.
    • Audit: Review App\Exceptions\Handler.php for existing error logging logic.
  2. Installation:
    composer require sinarajabpour1998/log-manager
    php artisan vendor:publish --tag=log-manager
    php artisan migrate
    
  3. Configuration:
    • Define log_types in config/log-manager.php.
    • Update App\Exceptions\Handler.php to include LogFacade::generateErrorLog($e).
  4. UI Integration:
    • Add <x-log-menu> to sidebar/layout Blade files.
  5. Validation:
    • Test LogFacade::generateLog("type") with a custom log type.
    • Trigger an exception to verify error logs populate.

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

  1. Phase 1 (Non-Prod):
    • Install in a staging environment.
    • Test facade, migration, and error logging.
    • Validate Blade component rendering.
  2. Phase 2 (Prod):
    • Deploy during low-traffic periods.
    • Monitor database growth and query performance.
  3. Phase 3 (Optimization):
    • Implement log archiving (e.g., monthly table partitioning).
    • Add rate-limiting to log generation (e.g., LogFacade::throttle(60)).

Operational Impact

Maintenance

  • Effort: Low to moderate.
    • Pros: Minimal moving parts (facade, migrations, Blade).
    • Cons: Abandoned package requires local patches for future Laravel updates (e.g., if BaseFacade breaks again).
  • Tooling:
    • Use php artisan package:discover to verify the package loads.
    • Add a pre-deploy check for facade resolution:
      // tests/Feature/LogFacadeTest.php
      public function test_facade_resolves()
      {
          $this->assertTrue(class_exists(\Sinarajabpour1998\LogManager\Facades\LogFacade::class));
      }
      
  • Deprecation risk: If Laravel deprecates Facade or Blade components, the package may need rewrites.

Support

  • Common issues:
    • Facade not found: Clear Laravel cache (php artisan optimize:clear).
    • Migration failures: Check for reserved column names (e.g., created_at conflicts).
    • Permission errors: Ensure log_types are defined before use.
  • Documentation gaps:
    • No examples for dynamic log types (e.g., adding types via API).
    • No guidance on log archiving or performance tuning.
  • Workarounds:
    • For error traces, consider masking sensitive paths (e.g., /vendor/) in error_trace.

Scaling

  • Database load:
    • Writes: Each LogFacade::generateLog() triggers a DB insert. High-volume apps may need:
      • Batch inserts (e.g., queue log generation).
      • Database indexing on log_type and created_at.
    • Reads: The <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);
      
  • Alternatives for scale:
    • Offload logs to a dedicated service (e.g., AWS CloudWatch, ELK) via Laravel’s logging channels.
    • Use database views to aggregate logs for the UI.

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

  • For developers:
    • Onboarding: Document the 3-step setup (Composer, migration, config) in a
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle