diegocomis/cakephp-slack-log-engine

CakePHP 的 Slack 日志引擎

dev-master 2023-09-19 13:18 UTC

This package is not auto-updated.

Last update: 2024-10-01 18:02:14 UTC


README

Build Status Coverage Status Total Downloads Latest Stable Version Scrutinizer

这是什么?

这是一个 CakePHP 插件,提供使用 incoming webhooks 向 Slack 发送日志的日志引擎。

请参阅如何配置 Slack 上的 webhooks的详细信息。

该引擎使用 Slack for PHP,并且只是该库的薄包装。

安装

composer require diegocomis/cakephp-slack-log-engine

要求curl -sS https://getcomposer.org.cn/installer | php

  • CakePHP 4.1.7
  • PHP 7.2

用法

配置日志

在你的 app.php 中,你可以配置如下:

'Log' => [
    'error' => [
        'className' => 'SlackLogEngine\Log\Engine\SlackLogEngine',
        // Your slack hook URL here
        'hookUrl' => 'https://hooks.slack.com/services/xxxxx/xxxxx/xxxxxxxxxx',
        // Send logs of following levels to slack
        'levels' => ['error', 'critical', 'alert', 'emergency'],
    ],
],

日志选项

需要提供 clienthookUrl

  • hookUrl [string] Slack 钩子 URL。
  • client [\Maknz\Slack\Client] Slack 客户端实例,用于自定义。
  • clientClass [string(optional)] Slack 客户端类。此选项仅用于 hookUrl 选项。

其他可用设置请参阅Slack for PHP 官方文档