rowasc/yii2loggingutils
最新稳定版本:1.0.1
Composer 安装命令:
composer require rowasc/yii2loggingutils
包简介
A very basic logging utility class. Designed to be used as a trait so you can use a default category depending on the class you are at .
README 文档
README
A very basic logging utility to help setup log categories from the controllers that "use" this trait/
Usage
##Configuration
In your Yii2's application config, under components=>log setup new logging categories you want to use
'components' =>[ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['info', 'error', 'warning', 'trace'], 'categories' => ['myawesomecategory'], 'logFile' => '@app/runtime/logs/myawesomecategory.log', 'maxFileSize' => 2048, 'maxLogFiles' => 10, 'logVars' => [] ]
Define your default log category for each class, so you have well defined categories to look into when something goes wrong.
namespace your\own\namespace; use rowasc\components\Log; class YourClass extends AnyClass { use Log; public $log_category="categoryOfYourLog"; public function yourFancyFunction(){ /** now use some loggers ! **/ $this->_logError("Error that you really want to log " ); $this->_logTrace($e); } }
If you want to have a different category for some messages, just override the category when calling the logging functions.
namespace your\own\namespace; use rowasc\components\Log; class YourClass extends AnyClass { use Log; public $log_category="categoryOfYourLog"; public function yourFancyFunction(){ /** now use some loggers ! **/ $this->_logError("Error that you really want to log " ,"myawesomecategory"); $this->_logTrace($e,"myerrorcategory"); } }
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-05