org_heigl / webhookhandler
一个向 webhook 发送 POST 请求的 monolog 处理器
1.1.1
2017-03-02 10:45 UTC
Requires
- php: ^7.0
- monolog/monolog: ^1.0
- php-http/async-client-implementation: ^1.0
- php-http/httplug: ^1.1
- php-http/message: ^1.5
Requires (Dev)
- guzzlehttp/guzzle: ^6.2
- php-http/mock-client: ^0.3
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-09-23 10:02:16 UTC
README
使用 HTTPlug 发送日志请求的日志处理器
安装
composer require org_Heigl/webhookhandler
使用方法
- 创建处理器
$uriFactory = \Http\Discovery\UriFactoryDiscovery::find(); $uri = $uriFactory->createUri('http://example.com/'); $handler = new WebHookHandler( $uri, Logger::DEBUG, \Http\Discovery\HttpAsyncClientDiscovery::find(), Http\Discovery\MessageFactoryDiscovery::find() ); $handler->setFrom('WhateverYouWant');
- 将处理器添加到日志记录器,就像添加其他处理器一样
$logger = new Logger('example'); $logger->pushHandler($handler);
- 按您习惯的方式记录日志
$logger->log('Whatever you want to say');
日志消息将通过 HTTP-POST 发送到提供的 URI(在此示例中为 http://example.com/)。
POST 体的内容如下 json 编码数组
[
[message] => The message of the log-entry
[from] => 'WhateverYouWant'
[context] => []
[level] => the set log-level
[level_name] => the name of the set log-level
[channel] => Whatever you set as channel name for the logger
[datetime] => DateTime-Object
[extra] => []
[formatted] => The formatted message
]
这主要是 monolog 传递给处理器的数组……