takshak/alogger
Composer 安装命令:
composer require takshak/alogger
包简介
Imager provider package for laravel
README 文档
README
Can be used for log / record user activity via middleware or by custom code. It has a route middleware Alogger::class and has view components to view logs lists and details in admin / user panel.
Quick Start
Install using given command:
composer require takshak/alogger
Run migration using php artisan migrate, loggers table will get migrated.
Use Alogger::class middleware in your routes in a group or individually.
use Takshak\Alogger\Http\Middleware\Alogger;
/* *
...
Route::middleware([Alogger::class])->group(function(){
Route::view('/', 'home');
/* *
...
});
See your all recorded logs via https://domain.com/aloggers
More Information
All logs will be stored in loggers table. You can set your preference in alogger.php. Run the following command to publish configurations.
php artisan vendor:publish --provider="Takshak\Alogger\AloggerServiceProvider"
Configuration (alogger.php)
log: you can disable or enable the logger by setting this value true or false
routes: wold to like to enable predefined routes (https://example.com/aloggers) to see all logs true or false
record: set all the available properties which will be recorded. status key will define tha this parameter needs to be recorded or not. except key will ignore (not record) the matching values
except: pass some urls where alogger will not work, matches: pass some parts of url, if current url matches any of these values, logs will not be recorded. urls: pass the exact url on which alogger will not log any data
max_rows: maximum number of rows stored in database
max_days: number of days. logs after these days will be deleted
Commands
php artisan alogger:prune This will prune the logs depend on max_rows and max_days. log more than max_rows and older than max_days will be deleted. You can set this command in your scheduler will be manage delete the older logs.
php artisan alogger:prune All logs will be cleared / flushed from database.
Components
It has two components with compatible with bootstrap 4 or 5
<x-alogger-loggers /> This component can be used to display all the logs on any page. This has some search and filters and view button for a popup to show the details of the log. You can pass paginate property to show number of items per page, default is 50 and order property to order the list by oldest first or latest first, default value is latest. Eg. <x-alogger-loggers paginate="100" order='latest' />
<x-alogger-logger logger-id="" /> This component will show the detail of a log. You need to pass the logger id for which you want to see the details
Using alogger manually
You can use Alogger Service to record the log manually from your controller or anywhere else.
use namespace Takshak\Alogger\Service;
/* * * /
$alogger = new Alogger;
$alogger->log(data: $data, remarks $remarks);
/* OR */
(new Alogger)->log(data: $data, remarks $remarks);
/* * Setting different properties * */
(new Alogger)->remarks('your remarks goes here')
->data($dataArray)
->user($userId_or_userModel)
->log();
Available methods to be used with Alogger Service
| Methods | Description |
|---|---|
| remarks($remarks, $data = null) | you can set remarks and data here |
| activity($activity, $data = null) | equivalent to remarks functions |
| data($data) | setting the data, if not set with remarks or activity method |
| user($user) | You can set user by passing user id or user model |
| log($user_id = null, $url = null, $data = null, $remarks = null) | logs the activity |
If you want to contribute, have any suggestion or want say something, please write to takshaktiwari@gmail.com
takshak/alogger 适用场景与选型建议
takshak/alogger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 takshak/alogger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 takshak/alogger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-27