teamnovu/laravel-notification-log

Logs every sent Notification and Mail of your entire Project.

v2.0.0 2023-08-18 23:56 UTC

This package is auto-updated.

Last update: 2024-11-05 19:20:11 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Logs every sent Notification and Mail of your entire Laravel Project.

Installation

You can install the package via composer:

composer require teamnovu/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 [

    /*
    |--------------------------------------------------------------------------
    | Compress Messages
    |--------------------------------------------------------------------------
    |
    | In case you send a lot of E-Mails the message_sent_logs table could become
    | very big. With this option you can enable that the body of every log
    | entry will be compressed with gzip to reduce its size.
    |
    */

    'compress-messages' => env('NOTIFICATION_LOG_COMPRESS_MESSAGES', false),
    
    /*
    |--------------------------------------------------------------------------
    | 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 Teamnovu\LaravelNotificationLog\Concerns\LogNotification;
use Teamnovu\LaravelNotificationLog\Contracts\ShouldLogNotification;

class DummyNotification extends Notification implements ShouldLogNotification
{
    use LogNotification;

    // ...
    
}

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.