inoovum / log-throwable
此包的最新版本(1.0.3)没有可用的许可证信息。
inoovum® 可抛日志包
1.0.3
2024-07-24 08:15 UTC
Requires
- neos/flow: ^7.0 || ^8.0 || ^8.1 || ^8.2 || ^8.3
README
此包扩展了可抛日志。
安装
只需运行:composer require inoovum/log-throwable
配置
您可以定义自己的PHP类。Neos Flow的异常消息将被传递给它们。例如,传递给特定的Slack频道。
Inoovum: Log: Throwable: options: writeToFile: false # Disable writing log files to local storage classes: - class: 'Inoovum\Log\Throwable\Log\SlackMessage' options: webhookUri: 'https://hooks.slack.com/services/T1TCCUN3X/A17PWTYX3GZ/xs83nHlpZafgUieYzsKiUcfa'
自定义可抛类
<?php
namespace Inoovum\Log\Throwable\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Neos\Flow\Annotations as Flow;
class SlackMessage implements ThrowableInterface
{
/**
* @param string $errorInfo
* @param array $options
* @return void
* @throws GuzzleException
*/
public function throwError(string $errorInfo, array $options): void
{
$client = new Client();
$url = $options['webhookUri'];
$client->post($url, [
'headers' => [
'Content-Type' => 'application/json',
],
'json' => [
'text' => $errorInfo
]
]);
}
}