承接 bert-w/laravel-log-viewer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bert-w/laravel-log-viewer

Composer 安装命令:

composer require bert-w/laravel-log-viewer

包简介

A fast Laravel log viewer to read any of your log files.

README 文档

README

Latest Stable Version Total Downloads License

A fast log file viewer for Laravel that is easy to add and configure.

Features

  • Compatible with Laravel 8 + 9 + 10
  • Read big log files with ease without reaching the memory limit
  • Includable in your own blade templates, or using a predefined layout
  • Bootstrap 3 + 4 + 5 templates
  • Bootstrap 5 comes with a Dark Mode setting
Dark Mode Light Mode

Installation

  1. Install package:
composer require bert-w/laravel-log-viewer
  1. (This happens automatically, except if you bypass package discovery) Add the service provider to your config/app.php:
'providers' => [
    // ...
    BertW\LaravelLogViewer\LogViewerServiceProvider::class,
]

The service provider sets up the views, routes, configuration and authentication. A \BertW\LaravelLogViewer\LogViewer::class is also bound as a singleton to the service container. This allows you to inject the log viewer anywhere (for instance in your custom controller) using $logViewer = app(\BertW\LaravelLogViewer\LogViewer::class). 3. a) (optional) Publish configuration file:

php artisan vendor:publish --provider=BertW\LaravelLogViewer\LogViewerServiceProvider
  1. b) or copy it manually into config/logviewer.php:
<?php

return [
    /*
    | The base URI for the log viewer.
    */
    'url' => '/logviewer',

    /*
    | The route name prefix to use for the logviewer route names.
    */
    'route_name_prefix' => 'logviewer.',

    /*
    | Display name for log files when they are listed in the interface, which is one of:
    | 'short' (filename only) or 'full' (absolute path).
    */
    'log_display_name' => 'short',

    /*
    | The title for the logviewer page. If `null`, no title is shown.
    */
    'title' => config('app.name') . ' Log Viewer',

    /*
    | The storage path that contains the logs to be displayed in the log viewer.
    */
    'storage_path' => storage_path('logs'),

    /*
    | The amount of lines from a log file that are read per page. The amount of logs that
    | are shown per page depends on this value, and it may differ depending on the
    | length of a single log record (Default: 3200).
    */
    'lines_per_page' => 3200,

    /*
    | The max length in bytes that a single line may have. Content that exceeds this limit will
    | be truncated from view. Note: disabling this feature with `null` may cause memory issues
    | with big log files that exceed this max line length (Default: 16000).
    */
    'max_line_length' => 16000,

    /*
    | The threshold in bytes for a log file to be marked as "big". This allows
    | the frontend to visually indicate that the log file is big (Default: 64MB).
    */
    'big_file_threshold' => 2**26,

    /*
    | The sorting order of the log files how they appear in the interface.
    */
    'sort_by' => ['modified_at', 'desc'],

    /*
    | Preselect the first log file based on the given ordering.
    | If `null`, no log file will be opened by default.
    */
    'preselect' => ['modified_at', 'desc'],
];
  1. By default, your log viewer should be available at /logviewer. For customization, see the Customization section below.

Authorization

Setting up authorization for the log viewer is easy: within any loaded service provider (like AppServiceProvider), add the following lines in your register() method:

\BertW\LaravelLogViewer\LogViewer::auth(function(\Illuminate\Http\Request $request) {
    return $request->user()->role === 'admin';
});

By default, if no custom authorization callback is given, the log viewer is only accessible in your local environment.

Customization

Including the log viewer in one of your own templates can be done simply by modifying the view file resources/views/vendor/logviewer/index.blade.php (available after the publish-command), which has the following default:

@extends('logviewer::bootstrap-5.layout')
@section('content')
    <div class="container">
        @include('logviewer::bootstrap-5.index')
    </div>
@endsection

The standard layout contains pre-included Bootstrap CSS/JS files linked from https://cdn.jsdelivr.net.

bert-w/laravel-log-viewer 适用场景与选型建议

bert-w/laravel-log-viewer 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 817 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 bert-w/laravel-log-viewer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-28