stepanenko3 / nova-logs-tool
A Laravel Nova 工具,用于管理和跟踪您的每个日志文件。
v2.2.2
2024-03-20 13:36 UTC
Requires
- php: >=8.0.0
- laravel/nova: ^4.0
- stepanenko3/laravel-log-viewer: *
Requires (Dev)
- phpstan/phpstan: ^1.10
- tightenco/duster: ^2.7
- dev-main
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- dev-dependabot/composer/tightenco/duster-tw-3.0
- dev-remove-base-tailwind-styles
- dev-fix-dark-mode
- dev-less-dependence-from-nova
- dev-version-2
This package is auto-updated.
Last update: 2024-08-31 14:34:25 UTC
README
描述
A Laravel Nova 工具,用于管理和跟踪您的每个日志文件。
功能
- 📂 在您的 storage/logs 目录中查看所有 Laravel 日志
- 📂 查看嵌套目录中的日志
- 🔍 搜索日志
- 🎚 通过日志级别(错误、信息、调试等)进行筛选
- 💾 从 UI 下载和删除日志文件
- ✅ 支持 Horizon 日志
- ⌚️ 轮询日志
- ⚫️ 暗黑模式
- 📱 响应式设计
- 🕔 显示加载时间和内存
要求
php: >=8.0
laravel/nova: ^4.0
安装
您可以通过 composer 将此包安装到使用 Nova 的 Laravel 应用中
composer require stepanenko3/nova-logs-tool
接下来,您必须将工具注册到 Nova 中。这通常在 NovaServiceProvider
的 tools
方法中完成。
// in app/Providers/NovaServiceProvder.php // ... public function tools() { return [ // ... new \Stepanenko3\LogsTool\LogsTool(), ]; }
发布包配置文件。
php artisan vendor:publish --provider="Stepanenko3\LogsTool\LogsToolServiceProvider"
授权
// in app/Providers/NovaServiceProvder.php // ... public function tools() { return [ // ... // don't return plain `true` value or anyone can see/download/delete the logs, make sure to check if user has permission. (new \Stepanenko3\LogsTool\LogsTool()) ->canSee(fn () => auth()->user()->canSee()) ->canDownload(fn () => auth()->user()->canDownload()) ->canDelete(fn () => true), ]; }
使用
点击您 Nova 应用中的 "nova-logs-tool" 菜单项,以查看此包提供的工具。
可能的环镜变量
LOG_VIEWER_FILES_ORDER=newest LOG_VIEWER_PER_PAGE=25
在仪表板显示最新日志
在 app/Nova/Metrics 中创建度量类
<?php namespace App\Nova\Metrics; use Carbon\Carbon; use Laravel\Nova\Metrics\MetricTableRow; use Laravel\Nova\Metrics\Table; use Stepanenko3\LaravelLogViewer\LogFile; class LatestLogs extends Table { private array $levels_classes = [ 'debug' => 'text-sky-500', 'info' => 'text-sky-500', 'notice' => 'text-sky-500', 'warning' => 'text-yellow-500', 'error' => 'text-red-500', 'critical' => 'text-red-500', 'alert' => 'text-red-500', 'emergency' => 'text-red-500', 'processed' => 'text-sky-500', ]; private array $level_icons = [ 'alert' => 'bell', 'critical' => 'shield-exclamation', 'debug' => 'code', 'emergency' => 'speakerphone', 'error' => 'exclamation-circle', 'info' => 'information-circle', 'notice' => 'annotation', 'warning' => 'exclamation', ]; public function __construct( protected ?string $file = null, protected int $countLastRow = 3, ) { // } public function calculate() { $logFile = LogFile::all()->first(); $query = LogFile::get( selectedFileName: $this->file ?: $logFile->name, page: 1, perPage: $this->countLastRow, direction: LogFile::NEWEST_FIRST, ); foreach ($query['logs'] as $line) { $rows[] = MetricTableRow::make() ->icon($this->level_icons[$line->level->value]) ->iconClass($this->levels_classes[$line->level->value]) ->title($line->text) ->subtitle(Carbon::create($line->time)->diffForHumans()); } return $rows; } }
将度量声明代码添加到 Dashboard 类的 Cards 方法中
(new LatestLogs('laravel.log', 3)), // Or show logs from last modified file (new LatestLogs(null, 5)),
屏幕截图
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
鸣谢
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。