seyfer / kohana-minion-log
该软件包最新版本(dev-3.3/master)没有提供许可证信息。
Kohana模块,用于在CLI环境中进行日志记录
dev-3.3/master
2015-01-09 05:24 UTC
Requires
- php: >=5.4
- composer/installers: 1.*
This package is auto-updated.
Last update: 2024-09-26 18:32:26 UTC
README
minion-log
是 Kohana Minion 的一个扩展,用于更方便地在命令行中处理日志。
安装
minion-log
应该添加到您的 Kohana MODPATH
目录中。然后在您的引导程序的 modules
部分中启用它。
要求
- kohana-minion 不是严格必需的,但这个库是在考虑到 minion/命令行接口的情况下编写的。
兼容性
- 为 Kohana 3.3 和 3.2 编写。
用法
此模块扩展了 Kohana 的 Log
类,可以使用相同的方式进行使用。请记住,您需要附加 Log_Writer
。
添加时写入
此模块的主要新增功能是能够在调用 $log->add()
方法时立即将数据写入指定的写入器。这在可能需要写入多个写入器的 CLI 环境中非常有用。例如,您可能希望立即将输出写入 StdOut,但延迟写入日志文件以避免过度使用系统 I/O。
这是通过将可选的第四个参数传递给 $log->attach()
来实现的。如果参数为 TRUE
,则在调用 $log->add() 时,将立即将输出写入该日志写入器。如果参数为 FALSE
(默认),则输出将在调用 $log->write() 时写入。
示例
这是一个使用 Minion_Log 的示例
$log = Minion_Log::instance(); // Or, just new Minion_Log
// Add the log file writer
$log->attach(new Log_File(APPPATH.'logs'));
// Add StdOut. Pass the other default parameters and the new $write_on_add parameter
$log->attach(new Log_StdOut, array(), 0, TRUE);
// This will immediately write to StdOut.
// Output will be buffered for the log file until $log->write() is called or the shutdown function is called
$log->add('Foobar');
// This will write to the log file, but not to StdOut (since that output was pushed immediately)
$log->write();
测试
此模块使用 unittest 模块 进行单元测试。您可以使用 minion.log
组仅运行 minion 日志测试。它也归类在 minion
下。
例如。
phpunit --group minion.log
有错误吗?问题呢?
这就是为什么它在github上托管的原因。请随意分支它,提交问题或补丁。
许可证
此软件的许可证与 Kohana 相同。