maxidev/tail-logger

Dynamic contextual logger for Laravel with Artisan tailing support

v1.0.0 2025-05-17 20:26 UTC

This package is auto-updated.

Last update: 2025-05-17 20:29:52 UTC


README

Dynamic, contextual, and tailable logging package for Laravel.

Easily log messages into daily log files organized by custom folders, with full support for structured context data and a built-in Artisan command for colored tailingβ€”even on Windows.

πŸš€ Features

βœ… Dynamic directory-based log storage
βœ… Daily rotating log files
βœ… Structured array/object context logging
βœ… Clean output format
βœ… Artisan command log:tail for real-time log viewing
βœ… Colorized output by log level (info, warning, error, success)
βœ… Cross-platform tailing (Windows & Unix)

πŸ“¦ Installation

composer require maxidev/tail-logger

If installing from local or VCS:

composer config repositories.max-logger path ../path/to/package
composer require maxidev/tail-logger:@dev

Laravel will auto-discover the service provider.

🧰 Usage

πŸ“„ Log to a custom path with optional level and context

use Maxidev\Logger\TailLogger;

// Basic log
TailLogger::saveLog('User login successful', 'auth/login');

// With level
TailLogger::saveLog('Invalid credentials', 'auth/login', 'warning');

// With context (array or object)
TailLogger::saveLog('Payment processed', 'billing/invoices', 'success', [
    'user_id' => 123,
    'amount' => 49.99,
    'currency' => 'USD'
]);

πŸ“ Log files are saved like:

storage/logs/auth/login/2025-05-17.log
storage/logs/billing/invoices/2025-05-17.log

πŸ” Real-time log tailing (with colors!)

php artisan log:tail auth/login
php artisan log:tail billing/invoices --date=2025-05-15
php artisan log:tail api/events --live

βœ… Fully compatible with Windows and Linux
🎨 Colorized output: green = success, yellow = warning, red = error

βš™οΈ Customization

You can fully control:

  • Path/folder structure
  • Log level (info, warning, error, success)
  • Context arrays
  • Date formatting in logs

Internally based on Monolog v3 and Laravel's logging conventions.

πŸ§ͺ Requirements

  • PHP 8.1+
  • Laravel 11 or 12
  • Composer

πŸ“„ License

MIT Β© Max