jeffreyvanrossum/wp-log
最新稳定版本:0.2.3
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.
统计信息
- 总下载量: 115
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-28