teamnovu/laravel-notification-log

记录项目中发送的每个通知和邮件。

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

This package is auto-updated.

Last update: 2024-09-05 18:59:28 UTC


README

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

记录整个Laravel项目中发送的每个通知和邮件。

安装

您可以通过composer安装此包

composer require teamnovu/laravel-notification-log

您可以使用以下命令发布和运行迁移

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

您可以使用以下命令发布配置文件

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

以下配置文件将发布到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),
];

使用方法

将以下接口和特性添加到您的通知中

use Teamnovu\LaravelNotificationLog\Concerns\LogNotification;
use Teamnovu\LaravelNotificationLog\Contracts\ShouldLogNotification;

class DummyNotification extends Notification implements ShouldLogNotification
{
    use LogNotification;

    // ...
    
}

现在可以像平时一样发送通知或邮件。该包将自动记录通知或邮件。

测试

composer test

变更日志

有关最近更改的更多信息,请参阅变更日志

鸣谢

许可协议

MIT许可协议(MIT)。有关更多信息,请参阅许可文件