rstriquer/eloquent-logger
Composer 安装命令:
composer require --dev rstriquer/eloquent-logger
包简介
Write SQL queries to a file into Laravel "storage/logs" directory.
README 文档
README
A package to allow logging of all SQL queries executed by an application built in Laravel by the eloquent ORM component.
This package builds a Laravel provider inside "vendors" folder which attaches a listener to the Eloquent Console Manager that writes ane query to a log output.
As the package is in vendors and installed in the dev, the developer does not need to worry about adding or removing codes from providers, as recommended in some pages on the internet, thus facilitating his day-to-day bases;
IMPORTANT:
- This module is not recommended for production use. It was built only for DEVELOPMENT environment;
- Considering the package writes all queries, it is recommended to keep it turned off, even in a development environment, and turn it on only when performing query improvement work since it may consume a considerable amount of size on HDD when running uninterruptedly;
- In very extreme and specific cases, where you are writing very (very) large contents (such as longtext fields or similar) it is possible that there are situations in which the plugin results in recording failures, depending on the limitations of your operating system (in old windows versions depending on FAT32 it may limit the size of the output file to less then 4gb);
- By and large at the end the log file is not that big but there is no logrotate functionality set therefore I recommend you monitor the log file size and delete it whenever necessary;
Minimum Requirements
This plugin was built when using Laravel version 8.0 and should work properly with any Laravel version after 8.
If you have the opportunity to successfully use this plugin in a previous laravel release please consider opening an issue to report your experience.
If you have any problems with this plugin please report it by following the steps on "Contributing" below.
How to install
Just run the following:
composer require rstriquer/eloquent-logger --dev
If you want you can personalize the log filename by setting the environment
variable DB_LOGGER_FILE. It works with .end file and the file must be
placed at storage directory.
how to use the plugin
Just set the environment variable DB_LOGGER_ACTIVE to true in your
.env file and run the application. The file set on DB_LOGGER_FILE
variable (which defaults to '/logs/query.log' located at the storage directory
at your application root folder) should contain all the queries performed by
that run sequentially.
To restrict the log file to the lasting 10 lines you can run the following sequence of commands:
tail -n 10 storage/logs/query.log > storage/logs/query.tmp && \ cat storage/logs/query.tmp > storage/logs/query.log && \ rm storage/logs/query.tmp
Contributing
The code is located in the Git repository at github. Contributions are most welcome by forking the repository and sending a pull request.
Discussions are done on GitHub issue tracker
Always remember to check on lint and types before post code:
composer run test:lint composer run test:types
PS: If necessary to fix lint you can just run composer run lint a couple of
times till it passes green and it will fix itself automatically.
To test a specific change you may configure your composer.json file in your project like described here
How to unit-test
This package make use of in memory sqlite to test its feature therefore be sure to have ext-sqlite installed on your system before running tests.
composer run test:unit
Code of Conduct
We follow and support the Laravel Code of Conduct and in order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Authors and License
This is an open source project by @rstriquer and licensed under MIT license.
rstriquer reserves the right to change the license in future releases without prior notification, but understand and agree that versions until such time remain under the MIT license as here described.
rstriquer/eloquent-logger 适用场景与选型建议
rstriquer/eloquent-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.38k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2023 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logger」 「laravel」 「debugger」 「dev」 「eloquent」 「laravel-dev」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rstriquer/eloquent-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rstriquer/eloquent-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rstriquer/eloquent-logger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This bundle lets you use the Tracy's debug screen in combination with the the default profiler in your Symfony application.
A fork of runcmf/runtracy
Use Google Cloud Logger into your Yii projects
Pop Debug Component for Pop PHP Framework
Workflow logger
HTTP request logger middleware for Laravel
统计信息
- 总下载量: 3.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-20