aledaas/loggerdb

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

Installs: 201

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/aledaas/loggerdb

v0.1.4 2025-08-15 02:39 UTC

This package is not auto-updated.

Last update: 2026-01-02 23:23:48 UTC


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.