|
1 | 1 | # Laravel Queue Event Logger |
2 | 2 |
|
3 | | -[](https://travis-ci.com/github/larawelders/queue-event-logger) |
| 3 | +Log Laravel queue worker lifecycle events to a dedicated `queue` log channel. |
4 | 4 |
|
5 | | -Log all details of queue events |
| 5 | +## Support Matrix |
6 | 6 |
|
7 | | -### TODO |
| 7 | +| Package | PHP | Laravel | |
| 8 | +| ------- | --- | ------- | |
| 9 | +| `2.x` | `8.2+` | `12.x` / `13.x` | |
8 | 10 |
|
9 | | -Write about self-contained jobs! |
| 11 | +Notes: |
| 12 | + |
| 13 | +- Laravel 12 supports PHP `8.2` through `8.5`. |
| 14 | +- Laravel 13 requires PHP `8.3+`, so PHP `8.2` is only valid with Laravel 12. |
| 15 | + |
| 16 | +## What It Logs |
| 17 | + |
| 18 | +- `JobProcessing` |
| 19 | +- `JobProcessed` |
| 20 | +- `JobQueued` |
| 21 | +- `JobExceptionOccurred` |
| 22 | +- `JobReleasedAfterException` |
| 23 | +- `JobFailed` |
| 24 | +- `JobTimedOut` |
| 25 | +- `Looping` |
| 26 | +- `QueueBusy` |
| 27 | +- `QueueFailedOver` |
| 28 | +- `QueuePaused` |
| 29 | +- `QueueResumed` |
| 30 | +- `WorkerStarting` |
| 31 | +- `WorkerStopping` |
| 32 | + |
| 33 | +## Installation |
| 34 | + |
| 35 | +```bash |
| 36 | +composer require larawelders/queue-event-logger |
| 37 | +``` |
| 38 | + |
| 39 | +The package uses Laravel package discovery, so no manual provider registration is required. |
| 40 | + |
| 41 | +The package registers a default `queue` log channel at runtime if your application does not already define one. By default, it uses a `single` channel that writes to `storage/logs/queue.log`. |
| 42 | + |
| 43 | +If you want to customize the channel name or logger configuration, publish the package config: |
| 44 | + |
| 45 | +```bash |
| 46 | +php artisan vendor:publish --tag=queue-event-logger-config |
| 47 | +``` |
| 48 | + |
| 49 | +The published config lets you change both the channel name and the underlying channel definition: |
| 50 | + |
| 51 | +```php |
| 52 | +'channel' => 'queue', |
| 53 | + |
| 54 | +'channel_config' => [ |
| 55 | + 'driver' => 'single', |
| 56 | + 'path' => storage_path('logs/queue.log'), |
| 57 | + 'level' => 'debug', |
| 58 | +], |
| 59 | +``` |
| 60 | + |
| 61 | +If your application already defines a channel with the configured name in `config/logging.php`, the application definition takes precedence: |
| 62 | + |
| 63 | +```php |
| 64 | +'channels' => [ |
| 65 | + 'queue' => [ |
| 66 | + 'driver' => 'single', |
| 67 | + 'path' => storage_path('logs/app-queue.log'), |
| 68 | + 'level' => 'info', |
| 69 | + ], |
| 70 | +], |
| 71 | +``` |
| 72 | + |
| 73 | +## Example Output |
| 74 | + |
| 75 | +```text |
| 76 | +[8f4d4f2e] Processing job App\Jobs\ProcessWebhook |
| 77 | +[8f4d4f2e] Processed job App\Jobs\ProcessWebhook |
| 78 | +[8f4d4f2e] Queued job App\Jobs\ProcessWebhook on queue webhooks with delay 30 |
| 79 | +[8f4d4f2e] Uncaught exception RuntimeException in job App\Jobs\ProcessWebhook: API timeout |
| 80 | +[8f4d4f2e] Released job after exception App\Jobs\ProcessWebhook with backoff 30 |
| 81 | +[8f4d4f2e] Job failed RuntimeException in job App\Jobs\ProcessWebhook: API timeout |
| 82 | +[8f4d4f2e] Timed out job App\Jobs\ProcessWebhook |
| 83 | +[worker] Looping |
| 84 | +[worker] Queue webhooks on connection redis is busy with 250 pending jobs |
| 85 | +[worker] Queue failover from connection redis for job App\Jobs\ProcessWebhook after RuntimeException: Redis down |
| 86 | +[worker] Paused queue webhooks on connection redis for 60 |
| 87 | +[worker] Resumed queue webhooks on connection redis |
| 88 | +[worker] Starting connection redis on queue webhooks |
| 89 | +[worker] Stopping with status 0 |
| 90 | +``` |
| 91 | + |
| 92 | +## Development |
| 93 | + |
| 94 | +```bash |
| 95 | +composer install |
| 96 | +composer run test |
| 97 | +composer run analyse |
| 98 | +``` |
0 commit comments