metalcoder/logsifier

管理应用程序日志的包

dev-master 2016-10-23 18:07 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:25:18 UTC


README

管理应用程序日志的包。

代码示例

只需使用 Facade Logsifier 来调用任何方法。

Logsifier::store('192.168.1.1','users','1','新用户创建','用户模块')

不要忘记在文件开头添加这一行

use Metalcoder/Logsifier/Logsifier;

动机

我参与了好几个项目,这些项目需要某种形式的日志操作。我决定首先创建自己的包,一来是为了在包开发中介绍自己,二来是为了在我未来的项目中使用。

安装

通过 composer 安装

  1. 将 "metalcoder/logsifier": "master-dev" 行添加到你的应用程序主 composer 的 require 部分。
  2. 执行 composer update
  3. 执行 php artisan migrate --path=vendor/metalcoder/logsifier/src/migrations 以运行负责创建日志表的包迁移。
  4. 在应用程序的 config/app.php 中添加 Metalcoder\Logsifier\MetalcoderLogsifierServiceProvider::class 到 providers 部分。
  5. 在 config/app.php 中添加 'Logsifier' => Metalcoder\Logsifier\Logsifier::class 到 aliases 部分。
  6. 在 config/app.php 中添加 Maatwebsite\Excel\ExcelServiceProvider::class 到 providers 部分。
  7. 在 config/app.php 中添加 'Excel' => Maatwebsite\Excel\Facades\Excel::class 到 aliases 部分。
  8. 执行 php artisan vendor:publish
  9. 现在你准备好了。

API 参考文档

该包公开了 4 个方法(截至当时),以帮助在任何 Laravel 应用程序中记录相关事件。

/* 将日志条目存储到数据库中的方法 */

  • 参数: $ip : 请求的 IP
  •   	        $object : Name of the database table the event is using
    
  •         $object_id : id of the element the event is using
    
  •             $description : Short descripcion of the event.
    
  •         $source : Name of the application module that triggered the event
    
  •         $urgent : If entry is marked as urgent an email will be sent to the recipients listed in config/logsifier.php
    

*/ Logsifier::store($ip,$object,$object_id,$description,$source,$urgent)

/* 显示所有日志条目的方法 */ Logsifier::index()

/* 将所有日志条目导出到 CSV 文件的方法 */ Logsifier::exportCSV()

/* 将所有条目导出到 CSV 文件并清空日志表的方法 */ Logsifier::rotate()

许可证

GNU 通用公共许可证