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

Eloquent Logger Laravel Package

rstriquer/eloquent-logger

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Use Case Alignment: Fits well for development debugging of Eloquent queries in Laravel, particularly for performance tuning, query optimization, and troubleshooting complex relationships.
  • Non-Intrusive: Leverages Laravel’s Service Provider pattern without requiring manual configuration (auto-registers in vendor/), reducing friction for developers.
  • Limited Scope: Focuses exclusively on SQL logging—no additional features (e.g., query analysis, metrics), which may require complementary tools (e.g., Laravel Debugbar, Blackfire) for broader observability.

Integration Feasibility

  • Low Barrier to Entry: Zero configuration required beyond package installation (composer require). Enabled via environment variable (ELOQUENT_LOGGER_ENABLED=true).
  • Dependency Constraints:
    • Requires Laravel 5.5+ (Eloquent ORM dependency).
    • No PHP version constraints, but Windows/FAT32 limitations may apply for large logs (see Failure Modes).
  • Database Agnostic: Works with any PDO-supported database (MySQL, PostgreSQL, SQLite, etc.).

Technical Risk

  • Performance Overhead:
    • Disk I/O Bottleneck: Continuous logging in high-traffic dev environments may degrade performance (not production-ready per README).
    • Memory Leaks: No explicit cleanup mechanism; long-running processes could exhaust disk space (requires manual monitoring).
  • Log File Management:
    • No Rotation: Risk of hitting filesystem limits (e.g., 4GB on FAT32) or filling storage (storage/logs/).
    • No Structured Logging: Raw SQL dumps lack metadata (timestamps, query duration, user context), complicating analysis.
  • Edge Cases:
    • Large Payloads: May fail silently for LONGTEXT/BLOB fields (OS/filesystem-dependent).
    • Multi-Tenant Apps: Logs lack tenant/environment context unless manually annotated.

Key Questions

  1. Dev Workflow Impact:
    • How will developers toggle logging without polluting production logs? (Environment variables vs. feature flags?)
    • Will the team adopt a log rotation strategy (e.g., cron job, Laravel scheduler) or rely on manual cleanup?
  2. Observability Gaps:
    • Are there plans to extend logging with query duration, parameter binding, or stack traces?
    • How will this integrate with existing tools (e.g., Laravel Telescope, Sentry)?
  3. Scalability:
    • For teams with CI/CD pipelines, how will logs be handled in ephemeral environments (e.g., GitHub Actions)?
    • Will the package support remote logging (e.g., Syslog, Papertrail) in future versions?
  4. Security:
    • Are there risks of sensitive data leakage (e.g., passwords in WHERE clauses) in logged queries?
    • Should logs be sanitized (e.g., redaction of API keys) before storage?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Native Integration: Designed for Eloquent; minimal conflict with other Laravel packages (e.g., Debugbar).
    • Complementary Tools:
      • Debugging: Pair with laravel-debugbar for real-time query analysis.
      • Performance: Use with blackfire/php for deep query profiling.
      • Monitoring: Export logs to Laravel Telescope for centralized review.
  • Non-Laravel Considerations:
    • Legacy PHP: Not applicable (Laravel-specific).
    • Alternative ORMs: No support for Doctrine, Eloquent-like libraries (e.g., October CMS).

Migration Path

  1. Pilot Phase:
    • Install in a non-production environment (e.g., local/dev branch).
    • Test with a subset of queries to validate log format and performance impact.
  2. Configuration:
    • Add to composer.json:
      "require-dev": {
        "rstriquer/eloquent-logger": "^1.0"
      }
      
    • Enable via .env:
      ELOQUENT_LOGGER_ENABLED=true
      ELOQUENT_LOGGER_FILE=eloquent.log
      
  3. CI/CD Adjustments:
    • Exclude log generation in production builds (e.g., via APP_ENV checks).
    • Add a pre-commit hook to warn if logs exceed a size threshold (e.g., 10MB).

Compatibility

  • Laravel Versions:
    • Tested on 5.5+; may work on older versions but untested.
    • Laravel 10+: Check for breaking changes in Eloquent’s event system.
  • PHP Extensions:
    • Requires PDO (standard in Laravel).
    • No other extensions needed.
  • Database Drivers:
    • Works with MySQL, PostgreSQL, SQLite, SQL Server (any PDO-supported).

Sequencing

  1. Short-Term:
    • Enable logging for critical query-heavy endpoints (e.g., admin dashboards).
    • Document toggle procedure for the team.
  2. Medium-Term:
    • Implement log rotation (e.g., Laravel scheduler task to truncate logs weekly).
    • Integrate with Telescope or custom middleware to enrich logs (e.g., add request_id).
  3. Long-Term:
    • Evaluate replacing with a feature-rich alternative (e.g., Spatie Laravel Query Logger) if scalability becomes an issue.
    • Advocate for database-level query logging (e.g., MySQL slow query log) as a complement.

Operational Impact

Maintenance

  • Developer Effort:
    • Low: No manual code changes required; toggle via .env.
    • High: Manual log cleanup if rotation is not automated.
  • Dependency Updates:
    • Minimal Risk: Package is lightweight and unlikely to break with Laravel minor updates.
    • Monitor for Eloquent event system changes in future Laravel versions.
  • Documentation:
    • Gaps: README lacks examples for multi-database setups or custom log paths.
    • Recommendation: Add a CONTRIBUTING.md with best practices (e.g., log analysis workflows).

Support

  • Troubleshooting:
    • Common Issues:
      • Logs not appearing → Verify ELOQUENT_LOGGER_ENABLED and storage/logs/ permissions.
      • File size limits → Check filesystem type (FAT32 vs. NTFS/ext4).
    • Debugging Tools:
      • Use tail -f storage/logs/eloquent.log for real-time monitoring.
      • Check Laravel logs (storage/logs/laravel.log) for package errors.
  • Community:
    • Limited Support: 4 stars, no open issues; rely on GitHub discussions or fork for fixes.
    • Alternatives: Consider spatie/laravel-query-logger (more active maintenance) if support is critical.

Scaling

  • Performance:
    • Dev Environments: Acceptable for small-to-medium query volumes; monitor disk I/O.
    • Load Testing: Disable during performance tests (adds ~5–10% overhead).
  • Log Management:
    • Manual Rotation: Risk of disk fills in long-running processes (e.g., Laravel Forge servers).
    • Automation: Implement a cron job or Laravel task to:
      // app/Console/Commands/CleanEloquentLogs.php
      public function handle() {
          $logPath = storage_path('logs/eloquent.log');
          if (filesize($logPath) > 10_000_000) { // 10MB
              file_put_contents($logPath, '');
          }
      }
      
  • Distributed Systems:
    • Multi-Server: Logs are local; consider centralized logging (e.g., ELK stack) for microservices.

Failure Modes

Failure Scenario Impact Mitigation
Log file exceeds filesystem limits Silent corruption/failure to log Monitor size; use NTFS/ext4
High query volume in dev Disk I/O saturation Disable during peak usage
Sensitive data in logged queries Compliance/privacy risk Sanitize logs or use a VPN/dev network
Package conflicts with other logs Overlapping log files Rename log file (e.g., eloquent.sql)
Laravel upgrade breaks listener Logging stops working Test on staging before production upgrade

Ramp-Up

  • Onboarding:
    • For Developers:
      • 5-minute guide: Install, enable, interpret logs.
      • Example: "To debug a slow User::with('posts')->get() query, enable logging and check for N+1 issues."
    • For PMs/Tech Leads:
      • Highlight non-production use only and disk space risks.
      • Suggest pairing with **
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope