aledaas/loggerdb 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aledaas/loggerdb

最新稳定版本:v0.1.4

Composer 安装命令:

composer require aledaas/loggerdb

包简介

DB-based process logging and email alerting for Laravel apps.

README 文档

README

DB-based process logging + email alerts.

Install (local path in monorepo)

In your app's root composer.json, add:

{
  "repositories": [
    { "type": "path", "url": "packages/loggerdb" }
  ]
}

Installation via Packagist

You can install LoggerDB using Composer by running:

composer require aledaas/loggerdb

LoggerDB supports Laravel versions 8.x, 9.x, and 10.x.

Configuration

To publish the configuration file, run:

php artisan vendor:publish --tag=loggerdb-config

This will create a config/loggerdb.php file where you can customize the package settings:

  • enabled (bool): Enable or disable logging and email alerts.
  • levels (array): The log levels to record and send alerts for (e.g. ['error', 'warning', 'critical']).
  • emails (array): Email addresses to receive alert notifications.
  • dedup_seconds (int): Number of seconds to deduplicate alerts to avoid spamming.

Database Migration

Run the package migrations to create the necessary tables:

php artisan migrate

Or, if you prefer to run only the package migrations:

php artisan migrate --path=vendor/aledaas/loggerdb/database/migrations

Usage

You can log processes using the ProcessLog model. Here is an example:

use Aledaas\LoggerDB\Models\ProcessLog;

ProcessLog::create([
    'process' => 'OrderProcessing', // The name of the process
    'step' => 'ValidateOrder',      // The current step in the process
    'level' => 'error',             // Log level: e.g. info, warning, error
    'outcome' => 'failed',          // Outcome of the step: e.g. success, failed
    'message' => 'Order ID 1234 failed validation.', // Descriptive message
    'context' => ['order_id' => 1234, 'user_id' => 5678], // Additional context data
]);

Fields explained:

  • process: Identifier for the process being logged.
  • step: Specific step or phase within the process.
  • level: Severity level of the log entry.
  • outcome: Result status of the step.
  • message: Human-readable description.
  • context: JSON-serializable array with extra metadata.

Email Alerts

If logging is enabled and the log level or outcome matches the configured criteria, LoggerDB will send alert emails to the addresses specified in the configuration. Alerts are deduplicated based on the dedup_seconds setting to prevent email spamming.

License

LoggerDB is open source software licensed under the MIT License.

统计信息

  • 总下载量: 176
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-14