定制 entensy/filament-tracer 二次开发

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

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

entensy/filament-tracer

最新稳定版本:0.1.7

Composer 安装命令:

composer require entensy/filament-tracer

包简介

Filament Tracer is a versatile package to report exceptions and traces. Table schemas are compatible with any language of choice.

README 文档

README

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

Filament tracer is a flexible filament plugin to report and view exceptions and traces with a generic table schema to be able to store traces from other programming languages.

The purpose of this package is to have a common tables to report/log errors throughout your applications, independent of what programming language you use so long as your application has a connection to the database, you can store the traces then later view them in filament dashboard.

Installation

This plugin requires Filament v3.0+, it does not work in older version!

Install the package via composer:

composer require entensy/filament-tracer

You could also use direct repository url in your composer.json:

"require": {
  "entensy/filament-tracer": "dev-main"
}
"repositories": [
  {
    "type": "git",
    "url": "https://github.com/entensy/filament-tracer.git"
  }
]

Usage

Register the plugin in your desired filament panel:

public function panel(Panel $panel): Panel
{
    return $panel
            ...
            ->plugins([
                FilamentTracerPlugin::make()
                    // You may define how you would like to get tab badge numbers, these must return int type
                    ->tracesCounterUsing(fn($record) => count( explode(PHP_EOL, $record->traces) ) ?? 0)
                    ->queriesCounterUsing(fn($record) => /** return int value */)
                    ->bodyCounterUsing(fn($record) => /** return int value */)
                    ->headersCounterUsing(fn($record) => /** return int value */)
                    ->cookiesCounterUsing(fn($record) => /** return int value */)
            ]);
}

To register capturing exceptions and errors, go to your app\Exceptions\Handler.php file and put the following snippet into register method:

$this->reportable(function (Throwable $e) {
    if ($this->shouldReport($e)) {
        \Entensy\FilamentTracer\FilamentTracer::capture($e, request());
    }
});

Theme

You may change the palette colors in your Filament Panel Service Provider:

$panel
    ->colors([
        'danger' => Color::Rose,
        'primary' => Color::Red,
        'success' => Color::Green,
        'warning' => Color::Yellow,
        'gray' => Color::Gray,
        'info' => Color::Blue,
    ])

Configuration

You may publish configuration using Laravel's publish command:

# Publish config file
php artisan vendor:publish --tag=filament-tracer-config

# Publish views
php artisan vendor:publish --tag=filament-tracer-views

# Publish translations
php artisan vendor:publish --tag=filament-tracer-translations

# Publish migrations
php artisan vendor:publish --tag=filament-tracer-migrations

Custom Tracer Class

You may write your own tracer class by changing the default class in the plugin config file. If you don't have this file, you may publish it with php artisan vendor:publish --tag=filament-tracer-config file:

[
...
    // You may implement your own tracer by implementing Tracerable interface
    'tracer' => \Entensy\FilamentTracer\DefaultTracer::class,
...
]

Defining a custom Tracer class has to implement Tracerable interface.

use Entensy\FilamentTracer\Contracts\Tracerable;

class MyCustomTracer implements Tracerable
{
    //
}

If you would like to change how an error being stored, you may overwrite this implementation by implementing HasStore interface in your custom tracer class then add your implementation in store method

use Entensy\FilamentTracer\Contracts\HasStore;
use Entensy\FilamentTracer\Contracts\Tracerable;

class MyCustomTracer implements Tracerable, HasStore
{
    public function store(): mixed
    {
        $err = $this->getThrowable():

        // just log the trace and don't store it in database
        logger()->error($err);

        return true;
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

Please email security@entensy.com for any security issues.

Credits

License

This repository is under MIT License (MIT).

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-14