aw-studio/logbook
Composer 安装命令:
composer require aw-studio/logbook
包简介
README 文档
README
This Package helps keeping track of what happens in your Laravel Application when it gets used Exceptions, Model events, incoming requests - all kind of information to help understand how users are using the application and beeing able to act accordingly.
Basic Usage
use AwStudio\Logbook\Facades\Logbook; class Action { public function execute() { Logbook::log(['action_executed' => static::class]); } }
Logging Model Changes
To track changes made on a model, just add the LogsEvents trait to your model:
class Post extends Model { use LogsEvents; }
Logging requests
class PostController extends Model { public function store(Request $request) { Logbook::request(); } }
Grouping Logs in a Batch
Using Logbook::open() you can group multiple logs into one batch. All logs performed, while a batch was opened
will receive the same unique batch identifier and optionally batch name:
class PostController extends Model { public function store(Request $request) { Logbook::open(); // or Logbook::open('Store new Post') Logbook::request(); // Do your magic Logbook::close(); } }
Logging Exceptions
Easily keep track of exceptions thrown in your application:
// App\Exceptions class Handler extends ExceptionHandler { use LogExceptions; public function register(): void { $this->reportable(function (Throwable $e) { Logbook::exception($e); }); } }
As Laravel doesn't report all Exceptions, like AuthenticationExceptions, ValidationExceptions and many more,
this trat provides a propety shouldLog which you may use to define Exceptions that should still be logged, event if
they are not reported:
protected $shouldLog = [ \Illuminate\Validation\ValidationException::class, ];
Logging Outgoing Mails
// App/Providers/EventServiceProvider class EventServiceProvider { use LogsOutgoingMessagesog; public function boot(){ $this->logOutGoingMessages(); } }
When the channel is Set to api, this will only log the messageID and subject to the API to
keep the user details secret but will also create a local log copy with which will also contain the messageID for better traceability.
Using the API Channel
By default, this package provides two different channels file and api.
When using the API Channel the logs are sent to the central Logbook API.
For this to work, you need to provide a LOGBOOK_PROJEKT_TOKEN in your .env file.
aw-studio/logbook 适用场景与选型建议
aw-studio/logbook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aw-studio/logbook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aw-studio/logbook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-31