cytec/zend-log-slack
最新稳定版本:3.1.0
Composer 安装命令:
composer require cytec/zend-log-slack
包简介
Write laminas-log messages to a slack channel
README 文档
README
Write laminas-log messages to a slack channel
Installation
composer require cytec/laminas-log-slack
Slack Configuration
The log writer works by sending information to a "Incoming WebHooks" integration in Slack:
- Open the channel you would like to receive your log in.
- Click on the channel name in the top left corner and from the drop down menu select "Add an app or integration"
- Click "Build" (top right)
- Click "Make a custom integration"
- Choose "Incoming WebHooks"
- Click the large green "Add Incoming WebHooks integration"
You'll need the Webhook URL to configure the writer. Under "Integration Settings" you can customize some defaults.
Usage
Manual
$writer = new \Cytec\Log\Writer\Slack('<YOUR_SLACK_WEBHOOK_URL>'); //Optional - use this filter only if you want to send critical messages to Slack $writer->addFilter(new \Laminas\Log\Filter\Priority(\Laminas\Log\Logger::CRIT)); $logger = new \Laminas\Log\Logger(); $logger->addWriter($writer); $logger->info('Informational message'); $logger->crit('Critical message'); //second "extra" parameter is supported and printed as properties in slack $logger->crit('Critical message', $_SERVER);
Via Service manager
Somewhere in your configuration (eg. config/autoload/global.php) add
... 'log' => [ 'SlackLog' => [ 'writers' => [ 'default' => [ 'name' => 'Cytec\Log\Writer\Slack', 'options' => [ 'webhook_url' => '<YOUR_SLACK_WEBHOOK_URL>', 'bot_name' => 'Project Name', //optional 'channel_override' => '#alerts',//optional @person is also supported 'filters' => \Laminas\Log\Logger::CRIT, //optional - filter by priority ] ] ] ] ], ...
And then you can get the logger via the service manager:
$log = $this->getServiceManager()->get('SlackLog'); $log->crit('Critical message');
Keep in mind
This writer isn't suitable for constant writing due to the fact that log messages are sent via http interface to the Slack api. This makes it very slow and can add significant delay in application response times. The intended use is for critical or very high priority messages that need the immediate attention of a real person.
统计信息
- 总下载量: 11.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-01-30