prowebcraft/yii2-log-helper
Composer 安装命令:
composer require prowebcraft/yii2-log-helper
包简介
Base helper class for better logging experience. Send messages to telegram
README 文档
README
Yii2 Log Helper
General usage
Attach \prowebcraft\yii2log\trait\Log trait to your class or extend it from \prowebcraft\yii2log\Log
Call static debug, info, warning or error method to log some info, for example:
<?php use \prowebcraft\yii2log\trait\Log; class MarsExpedition { use Log; public function doHeavyJob(){ self::info('Prepare to launch'); $missionInfo = [ 'title' => 'Mission to Mars', 'distance' => '54.6m km', 'pilot' => 'Elon Musk', ]; self::debug('Flight data: %s', $missionInfo); try { // mission inpossible } catch($e) { self::error('Error flying to Mars: %s', $e); } } }
Configuration
Send messages to telegram
To send error/warning messages to telegram add component and log target to your config (ex. common/main-local.php):
'components' => [ // ... 'telegram' => [ 'class' => \prowebcraft\yii2log\TelegramBot::class, 'token' => '123:xyz' // telegram bot token, 'defaultChatId' => -1000000000, // group or channel id, 'targetPerCategory' => [ 'mission_control' => -20000000 ], ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => \prowebcraft\yii2log\TelegramTarget::class, 'levels' => ['error', 'warning'], // log levels 'logVars' => [] ] ], ], // ... ], ];
Output messages to console
To output messages to console in Console applications log target to your config (ex. console/main-local.php):
'components' => [, 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'flushInterval' => 1, 'targets' => [ [ 'class' => \prowebcraft\yii2log\ConsoleTarget::class, 'levels' => ['error', 'warning', 'info', 'trace'], 'logVars' => [], 'displayCategory' => true, 'except' => [ 'yii\*' ], 'exportInterval' => 1, ] ], ], ], ];
统计信息
- 总下载量: 1.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-4-Clause
- 更新时间: 2022-04-27