PHPackages                             artemyurov/moonshine-db-joblog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. artemyurov/moonshine-db-joblog

ActiveLibrary

artemyurov/moonshine-db-joblog
==============================

Job logging with MoonShine admin panel for Laravel queue jobs

v1.0.6(today)139↑438.5%MITPHPPHP ^8.2

Since Feb 27Pushed todayCompare

[ Source](https://github.com/ArtemYurov/moonshine-db-joblog)[ Packagist](https://packagist.org/packages/artemyurov/moonshine-db-joblog)[ RSS](/packages/artemyurov-moonshine-db-joblog/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (8)Used By (0)

MoonShine DB JobLog
===================

[](#moonshine-db-joblog)

[![PHP](https://camo.githubusercontent.com/5fe05c705bf034839bda7651781e4d0a9d42f4a840478ca5e343873a0361bb89/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322b2d626c75652e737667)](https://php.net)[![Laravel](https://camo.githubusercontent.com/a93f6c4babc6cd489af5e6ac4584e9cb55ba6ea2feeba090a9e586876ab137c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312e7825374331322e782d7265642e737667)](https://laravel.com)[![MoonShine](https://camo.githubusercontent.com/693680915a4bf4311b0d560dff3d86af1ad1318dcc424be3ac415d33ae04efff/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6f6f6e5368696e652d342e782d707572706c652e737667)](https://moonshine-laravel.com)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

**[Русская версия (README.ru.md)](README.ru.md)**

Job queue logging package with [MoonShine](https://moonshine-laravel.com) admin panel integration for Laravel.

Track your queue jobs in real-time: statuses, steps, progress, errors — all visible in MoonShine admin.

Features
--------

[](#features)

- Automatic tracking of queue job lifecycle (queued → processing → processed/failed)
- Step-by-step progress with named steps
- PSR-3 compatible logging (emergency, alert, critical, error, warning, notice, info, debug)
- Polymorphic `related` relation — link any Eloquent model to a job
- Auto-detection of the first Eloquent model from job constructor arguments
- Color-coded console output during `artisan` execution
- MoonShine admin resources with filters, query tags, and detail views
- Laravel Horizon integration (tag resolution, purge interception)
- Configurable cleanup schedule and job scan paths
- i18n support (EN, RU out of the box)

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.x or 12.x
- MoonShine 4.x

Installation
------------

[](#installation)

```
composer require artemyurov/moonshine-db-joblog
```

The package auto-discovers the service provider. Run migrations:

```
php artisan migrate
```

Optionally publish the config:

```
php artisan vendor:publish --tag=joblog-config
```

### Localization

[](#localization)

The package ships with EN and RU translations. Publish to customize:

```
php artisan vendor:publish --tag=joblog-lang
```

Files will be placed in `lang/vendor/joblog/`. Translation namespace: `joblog::joblog`.

Quick Start
-----------

[](#quick-start)

### 1. Add the Loggable trait to your job

[](#1-add-the-loggable-trait-to-your-job)

```
use ArtemYurov\JobLog\Traits\Loggable;

class ProcessOrderJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    use Loggable;

    public function __construct(
        public readonly Order $order
    ) {}

    public function handle(): void
    {
        $this->log()->info('Starting order processing');

        // Your job logic...

        $this->log()->info('Order processed successfully');
    }
}
```

The `Order` model will be automatically detected as the `related` model.

### 2. Define steps for complex jobs

[](#2-define-steps-for-complex-jobs)

```
class ImportDataJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    use Loggable;

    protected function steps(): array
    {
        return [
            'download'  => 'Download data',
            'validate'  => 'Validate records',
            'import'    => 'Import to database',
            'cleanup'   => 'Cleanup temp files',
        ];
    }

    public function handle(): void
    {
        $this->log()->step('download')->info('Downloading...');
        // ... download logic
        $this->log()->step('download')->processed();

        $this->log()->step('validate')->info('Validating...');
        // ... validation logic
        $this->log()->step('validate')->processed();

        $this->log()->step('import')->info('Importing...');
        foreach ($records as $i => $record) {
            // ... import logic
            $this->log()->step('import')->setProgressFromCounts($i + 1, count($records));
        }
        $this->log()->step('import')->processed();

        $this->log()->step('cleanup')->info('Cleaning up...');
        // ... cleanup logic
        $this->log()->step('cleanup')->processed();
    }
}
```

Progress is automatically calculated based on completed steps (enabled by default). To disable, call `$this->disableAutoStepProgress()` in your job.

### 3. Register MoonShine resources

[](#3-register-moonshine-resources)

```
// In your MoonShineLayout or MoonShineServiceProvider
use ArtemYurov\JobLog\MoonShine\Resources\JobLogResource;

MenuItem::make('Job Logs', JobLogResource::class),
```

Usage
-----

[](#usage)

### Logging methods (PSR-3)

[](#logging-methods-psr-3)

```
$this->log()->emergency('System is unusable');
$this->log()->alert('Action must be taken');
$this->log()->critical('Critical condition');
$this->log()->error('Error occurred', ['code' => 500]);
$this->log()->warning('Warning message');
$this->log()->notice('Normal but significant');
$this->log()->info('Informational message');
$this->log()->debug('Debug details', ['query' => $sql]);
```

### Exception logging

[](#exception-logging)

```
try {
    // risky operation
} catch (\Throwable $e) {
    $this->log()->exception($e, 'Optional custom message');
    $this->log()->step('import')->failed($e);
}
```

### Progress tracking

[](#progress-tracking)

```
// Set exact progress (0-100)
$this->log()->progress(50);
$this->log()->step('import')->progress(75);

// Calculate from counts
$this->log()->step('import')->setProgressFromCounts($processed, $total);

// Increment
$this->log()->step('import')->incrementProgress(5);
```

### Step status management

[](#step-status-management)

```
$step = $this->log()->step('validate');

$step->start();       // alias for processing()
$step->processing();  // set status to PROCESSING
$step->processed();   // set status to PROCESSED, progress to 100%
$step->failed();      // set status to FAILED

// Custom status (displayed alongside the standard status)
$step->customStatus('Waiting for API response');
$step->customStatus('Rate limited', 'API returned 429');
```

### Data storage

[](#data-storage)

```
// Store key-value data on job or step
$this->log()->addData(['total_records' => 1500]);
$this->log()->step('import')->addData(['skipped' => 3, 'errors' => 1]);

// Retrieve data
$total = $this->log()->getData('total_records');
$allData = $this->log()->step('import')->getData();
```

### Explicit related model

[](#explicit-related-model)

By default, the first Eloquent model in constructor arguments is auto-detected. Override this:

```
class SyncJob implements ShouldQueue
{
    use Loggable;

    public function __construct(
        public readonly Branch $branch,
        public readonly array $options
    ) {}

    // Explicitly define the related model
    public function related(): Branch
    {
        return $this->branch;
    }
}
```

### Hiding sensitive arguments

[](#hiding-sensitive-arguments)

Constructor arguments are automatically serialized and stored in the database. Use PHP 8.2 `#[\SensitiveParameter]` attribute to mask sensitive values:

```
class SendPaymentJob implements ShouldQueue
{
    use Loggable;

    public function __construct(
        public readonly Order $order,
        #[\SensitiveParameter] public readonly string $apiKey,
        #[\SensitiveParameter] public readonly string $secretToken,
    ) {}
}
```

In the database and MoonShine UI, sensitive arguments will be stored as `********`.

Extending the resource
----------------------

[](#extending-the-resource)

Create a custom resource that extends `JobLogResource` to add domain-specific formatting:

```
use ArtemYurov\JobLog\MoonShine\Resources\JobLogResource;

class MyJobLogResource extends JobLogResource
{
    protected function formatRelated(JobLog $item): string
    {
        if ($item->related instanceof Branch) {
            return $item->related->city ?? "Branch #{$item->related->getKey()}";
        }

        return parent::formatRelated($item);
    }
}
```

Configuration
-------------

[](#configuration)

```
// config/joblog.php
return [
    // Cleanup old records
    'cleanup' => [
        'days' => (int) env('JOBLOG_CLEANUP_DAYS', 30),
        'schedule' => env('JOBLOG_CLEANUP_SCHEDULE', false), // false, 'daily', 'weekly', 'hourly'
        'time' => env('JOBLOG_CLEANUP_TIME', '03:00'),
    ],

    // Console output during artisan commands
    'console_output' => (bool) env('JOBLOG_CONSOLE_OUTPUT', true),

    // Laravel Horizon integration (detected automatically)
    'horizon' => [
        'intercept_purge' => (bool) env('JOBLOG_HORIZON_INTERCEPT_PURGE', true),
    ],

    // Paths to scan for Loggable jobs (for filter dropdown)
    'job_class_scan_paths' => [
        // Defaults to app/Jobs
    ],
];
```

Artisan commands
----------------

[](#artisan-commands)

```
# Cleanup records older than N days (default: 30)
php artisan joblog:cleanup
php artisan joblog:cleanup --days=7

# Truncate all records
php artisan joblog:truncate
```

License
-------

[](#license)

MIT

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance100

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

7

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffb938044c91bebfb7bc0aca76e9dae0c7b975080de1b253210617d1c61744c4?d=identicon)[ArtemYurov](/maintainers/ArtemYurov)

---

Top Contributors

[![ArtemYurov](https://avatars.githubusercontent.com/u/13986502?v=4)](https://github.com/ArtemYurov "ArtemYurov (24 commits)")

---

Tags

laravel-packagelaravel-packagesmoonshinemoonshine-laravelmoonshine-plugin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/artemyurov-moonshine-db-joblog/health.svg)

```
[![Health](https://phpackages.com/badges/artemyurov-moonshine-db-joblog/health.svg)](https://phpackages.com/packages/artemyurov-moonshine-db-joblog)
```

###  Alternatives

[laravel/lumen-framework

The Laravel Lumen Framework.

1.5k25.9M651](/packages/laravel-lumen-framework)[yzen.dev/mono-processor

This Processor will display in the logs bread crumbs by which you can more quickly and accurately identify the cause of the error.

116.1k](/packages/yzendev-mono-processor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
