jeffreyvanrossum/wp-log
Composer 安装命令:
composer require jeffreyvanrossum/wp-log
包简介
Package to allow for simple logging with interface.
README 文档
README
WP Log
A simple package to write entries to a log file.
Installation
composer require jeffreyvanrossum/wp-log
Usage
You can setup your log with:
$log = new \Jeffreyvr\WPLog\Log('Your log');
You can define a custom file path, if you don't, the default is the wp-content/uploads/ folder with the file name being a sanitized version of your log name.
$log->setFilePath(wp_upload_dir()['basedir'] . '/logs/your-log-filename.log');
Writing to your log can be done like so:
$log->write('Your log message'); $log->write(['foo' => 'bar']);
You may clear your log with:
$log->clear();
The interface method will render an interface, which you can use to display the log somewhere in the admin area.
If you want to display the log page in the admin menu, you can call:
$log->interface()->inAdminMenu(slug: 'optional-slug', parent: 'tools.php');
To set a custom capability use:
$log->interface->setCapability('manage_options');
Or if you want to add it as a plugin link instead:
$log->interface()->asPluginLink(basename: plugin_basename(__FILE__), slug: 'optional-slug');
You can instead also call $log->interface()->render() to render it somewhere you want.
To prevent your log from becoming very large, the default limit is set to 1000 items. You can overwrite this:
$log->setClearLimit(100); // If you don't want to limit your log, you can pass 0. $log->setClearLimit(0);
Contributors
License
MIT. Please see the License File for more information.
jeffreyvanrossum/wp-log 适用场景与选型建议
jeffreyvanrossum/wp-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 160 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jeffreyvanrossum/wp-log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeffreyvanrossum/wp-log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 160
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-28