定制 kerodev/filament-logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kerodev/filament-logger

Composer 安装命令:

composer require kerodev/filament-logger

包简介

Activity logger for filament

README 文档

README

Note

This is a fork of Z3d0X/filament-logger with Filament 4 support. Now maintained by keroles19 with improvements and bug fixes.

Activity logger for filament

Latest Version on Packagist Total Downloads

Configurable activity logger for filament. Powered by spatie/laravel-activitylog

Features

You can choose what you want to log and how to log it.

  • Log Filament Resource Events
  • Log Login Event
  • Log Notification Events
  • Log Model Events
  • Easily extendable to log custom events

Note: By default this package will log Filament Resource Events, Access(Login) Events, and Notification Events. If you want to log a model that is not a FilamentResource you will have to manually register in the config file.

Development (Git hooks)

This repo includes a commit-msg hook that removes any Made-with: Cursor line from commit messages so it is never stored in history (some editors append that automatically).

After cloning, run once from the package root:

composer run setup-git-hooks

Or manually:

git config core.hooksPath .githooks
chmod +x .githooks/commit-msg

If a commit tool bypasses hooks, you can still amend with hooks disabled only when needed: git -c core.hooksPath=/path/to/empty/dir commit --amend ….

Installation

Plugin Version Filament Version
<= 0.5.x ^2.11
0.6.x - 0.8.x 3.x
>= 1.0 4.x

This package uses spatie/laravel-activitylog, instructions for its setup can be found here

You can install the package via composer:

composer require kerodev/filament-logger

After that run the install command:

php artisan filament-logger:install

This will publish the config & migrations from spatie/laravel-activitylog

Register the plugin in your PanelProvider:

use Keroles\FilamentLogger\FilamentLoggerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentLoggerPlugin::make(),
        ]);
}

Authorization

To enforce policies on ActivityResource, after generating a policy, you would need to register Spatie\Activitylog\Models\Activity to use that policy in the AuthServiceProvider.

<?php
 
namespace App\Providers;
 
use App\Policies\ActivityPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Spatie\Activitylog\Models\Activity;
 
class AuthServiceProvider extends ServiceProvider
{
    protected $policies = [
        // Update `Activity::class` with the one defined in `config/activitylog.php`
        Activity::class => ActivityPolicy::class,
    ];
    //...
}

If you are using Shield just register the ActivityPolicy generated by it

Translations

Publish the translations using:

php artisan vendor:publish --tag="filament-logger-translations"

Activity Model resolution

The main Activity class being used by the Filament Resource instance will be resolved by Spatie's service provider, which loads the model defined by the configuration key found at activitylog.activity_model in config/activitylog.php.

Configurable Activity resource & table UI

Publish config/filament-logger.php and adjust:

  • activity_resource: class used when registering the Filament plugin and list/view pages. Point this to your own Resource subclass if you need custom authorization, queries, or pages.
  • table.global_search: enable the search field on the activity list (searches description, event, log name, subject type, and numeric subject id).
  • table.global_search_properties_old_attributes: when global_search is on, also match Spatie’s properties.old and properties.attributes (the “new” values) using LIKE on the JSON text, so both attribute names and values are searchable (default true). Set to false on very large tables if needed.
  • table.resolve_subject_label: when the subject model exists, show ModelName: {name} using common attributes (name, title, email, slug, or getName()).
  • table.eager_load_relations: relations to eager load on the index query (default subject, causer).
  • table.bulk_delete / table.row_delete: show bulk delete on the list and/or per-row delete + delete on the view page. Off by default.
  • table.include_spatie_default_in_type_filter: include Spatie’s default log_name (default) in the type filter and badge colors (useful when using LogsActivity only).

Avoiding duplicate rows (default + Resource + Model)

If you also use Spatie’s LogsActivity on models and leave resources.enabled and models.enabled on, the same save can create up to three activity rows (default, Resource, Model). Pick one CRUD pipeline per project, for example:

  • Spatie-only: set resources.enabled and models.enabled to false, keep LogsActivity on your models; or
  • Package observers only: disable LogsActivity where redundant and use Resource/Model loggers.

Keep access / notifications enabled if you still want login and notification logs.

Deleting activity rows (AuthorizesActivityDeletion)

Bulk and row deletes (when enabled in table.*_delete) are gated by Keroles\FilamentLogger\Contracts\AuthorizesActivityDeletion. The package binds a default implementation that denies all deletes.

In your app’s AppServiceProvider::register() (or a service provider that loads early), bind your own rules, for example:

use Keroles\FilamentLogger\Contracts\AuthorizesActivityDeletion;

$this->app->singleton(AuthorizesActivityDeletion::class, function () {
    return new class implements AuthorizesActivityDeletion {
        public function canDelete(?\Illuminate\Contracts\Auth\Authenticatable $user): bool
        {
            return $user !== null && $user->can('deleteAny', \Spatie\Activitylog\Models\Activity::class);
        }
    };
});

You can also register an ActivityPolicy (see Authorization above) and delegate to Gate as in the example.

Screenshots

Activity logs (list)

Table with type, event, subject (including resolved names), user, and timestamps. Sortable columns.

Activity logs list

Search, filters, and bulk actions

Global search, active filters (e.g. by user), row actions (view / delete), and bulk delete when enabled in config.

Activity logs with search, filters, and bulk actions

View activity log (detail)

Single log view with metadata and Old vs New attribute comparison (Spatie properties).

View activity log with old and new attributes

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

kerodev/filament-logger 适用场景与选型建议

kerodev/filament-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「activity-log」 「filament」 「Z3d0X」 「filament-logger」 「kerodev」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kerodev/filament-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kerodev/filament-logger 我们能提供哪些服务?
定制开发 / 二次开发

基于 kerodev/filament-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-10