定制 macellan/kmd-logviewer 二次开发

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

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

macellan/kmd-logviewer

Composer 安装命令:

composer require macellan/kmd-logviewer

包简介

Laravel 4 log file viewer.

README 文档

README

#Laravel 4 LogViewer

Easily view and delete Laravel 4's logs.

Inspiration from Fire Log for CodeIgniter by David Morrow and Larvel Log Viewer for Laravel 3 by Eric Barnes

Created and maintained by Micheal Mand. Copyright © 2013. Licensed under the MIT license.

Build Status Total Downloads

#A note about Laravel 4.1

As of right now (2013-11-29), fresh Laravel 4.1 applications log things differently than they used to. While this doesn't technically break LogViewer, LogViewer also doesn't know how to handle these changes. Here's a quick fix:

In your app/start/global.php, line 34 change:

Log::useFiles(storage_path().'/logs/laravel.log');

to:

$logFile = 'log-'.php_sapi_name().'.txt';

Log::useDailyFiles(storage_path().'/logs/'.$logFile);

This only applies to new installations of Laravel 4.1. If you've upgraded an existing 4.0 application (and did not make changes to the way logs are created and stored), everything should still work.

##Demo

View the demo here

##Installation

Add kmd/logviewer as a requirement to composer.json:

{
    ...
    "require": {
        ...
        "kmd/logviewer": "1.2.*"
        ...
    },
}

Update composer:

$ php composer.phar update

Add the provider to your app/config/app.php:

'providers' => array(

    ...
    'Kmd\Logviewer\LogviewerServiceProvider',

),

Publish package assets:

$ php artisan asset:publish kmd/logviewer

(Optional) You can configure your composer.json to do this after each $ composer update:

"scripts":{
    "post-update-cmd":[
        "php artisan asset:publish kmd/logviewer",
        "php artisan optimize",
    ]
},

(Optional) Publish package config:

$ php artisan config:publish kmd/logviewer

Please note: if you have made changes in your app/config/packages/kmd/logviewer/config.php, DO NOT publish the package config again. It will overwrite yours without any warning.

##Usage and Configuration

###Usage

By default, LogViewer will register itself a couple of routes:

  • logviewer -> Redirect to today's log, showing all levels.
  • logviewer/$app/$sapi/$date/delete -> Delete log from $sapi (see: php_sapi_name) on $date (Y-m-d format).
  • logviewer/$app/$sapi/$date/$level? -> Show log from $sapi on $date with $level (if not supplied, defaults to all).

LogViewer also registers a couple filters:

  • logviewer.logs: aggregates all the logs in your configured monitored directories and shares them with the $logs variable.
  • logviewer.messages: Checks if there are success, error, or info flash messages in the session and sets the $has_messages variable as true or false.

###Configuration

  • base_url: The URL LogViewer will be available on. You can have this nested (for example: admin/logviewer). Default: logviewer.
  • filters: Before and After filters to apply to the routes. We define no filters by default, as not everyone uses authentication or the same filter names.
    • global: Filters that affect the entirety of the logviewer. For example: 'global' => array('before' => 'auth'), will apply the default Laravel auth filter to the logviewer, requiring a logged in user for all routes.
    • view: Filters that affect the viewing of log files.
    • delete: Filter that affect the deletion of log files.
  • log_dirs: Associative array of log directories to monitor. Array keys are the 'names' of your applications, values are the paths to their app/storage/logs dir (no trailing slash). Default: array('app' => storage_path().'/logs').
  • log_order: Order log contents ascending or descending. Default: 'asc'.
  • per_page: The number of log messages to show per page via Pagination. Default: 10.
  • view: The name (and location) of the view used to display logs. For more information, check out the 'Advanced Usage' section for detailed information about the variables passed to this view. Default: 'logviewer::viewer'.
  • p_view: The pagination view to use. When using Bootstrap 3 as the default for an application, the pagination would be broken within LogViewer. If you create your own view, be sure to change this if you use Bootstrap 3 (or write your own pagination view) Default: 'pagination::slider'.

Advanced Usage

Don't like the way LogViewer looks? Need to integrate it better with your application's theme? You can do so by creating your own view and changing the configuration option. Here are the variables that are sent to the view:

  • $has_messages: Boolean. The logviewer.messages filter determines if there are success, error, or info flash messages in the session. Used to hide the flash messages container.
  • $logs: Array. Aggregated logs, generated by the logviewer.logs filter, from all monitored applications. Grouped by SAPI and application. Structure:
    • SAPI as key, value is an array with keys:
      • sapi: Human-readable SAPI.
      • logs: Application 'short name' as key, value is an array of log dates.
  • $log: Array. Currently selected log's contents. Each message is split into an array. Structure:
    • level: String. The level of the log message.
    • header: String. The first line of the log message.
    • stack: String. The rest of the log message. Possibly blank, if the message did not contain a stack trace.
  • $empty: Boolean. Whether the current log is empty or not.
  • $date: String. The date of the currently selected log.
  • $sapi: String. The human-readable SAPI of the currently selected log.
  • $sapi_plain: String. The SAPI of the currently selected log. Used in the URI.
  • $url: String. The base URL from configuration.
  • $levels: Array. All possible log levels, per psr/log.
  • $path: String. The array key of the currently selected log's application.

macellan/kmd-logviewer 适用场景与选型建议

macellan/kmd-logviewer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 406 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 09 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 macellan/kmd-logviewer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-15