okaufmann/laravel-notification-log

Logs every sent Notification and Mail of your entire Project.

4.6.0 2024-10-01 18:49 UTC

This package is auto-updated.

Last update: 2024-10-01 19:08:54 UTC


README

Latest Version on Packagist Tests PHPStan Check & fix styling Total Downloads

Logs every sent Notification of your entire Laravel Project.

Installation

You can install the package via composer:

composer require okaufmann/laravel-notification-log

You can publish and run the migrations with:

php artisan vendor:publish --tag="notification-log-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="notification-log-config"

The following config file will be published in config/notification-log.php:

return [
    
    /*
    |--------------------------------------------------------------------------
    | Resolve Notification Message
    |--------------------------------------------------------------------------
    |
    | If this is enabled, the Logger will try to resolve the built message
    | out of the notification. This is useful if you want to debug your
    | sent notifications.
    |
    */

    'resolve_notification_message' => env('NOTIFICATION_LOG_RESOLVE_NOTIFICATION_MESSAGE', false),
];

Usage

Add the following Interface and Trait to your Notification:

use Okaufmann\LaravelNotificationLog\Contracts\ShouldLogNotification;use Okaufmann\LaravelNotificationLog\Models\Concerns\LogsNotifications;

class DummyNotification extends Notification implements ShouldLogNotification
{
    use LogsNotifications;

    // ...
    
}

Now send a Notification or Mail as you would normally do. The package will automatically log the Notification or Mail.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.