org_heigl / webhookhandler
A monolog-handler that POSTs to a webhook
Installs: 1 835
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
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-11-23 10:18:25 UTC
README
Log-Hander that POSTs a log-request using HTTPlug
Installation
composer require org_Heigl/webhookhandler
Usage
- Create the handler
$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');
- Add the handler to the logger as you would with any other handler:
$logger = new Logger('example'); $logger->pushHandler($handler);
- Log as you are used to:
$logger->log('Whatever you want to say');
The log-message will be send via a HTTP-POST to the provided URI (in this example to ```http://example.com/``).
The post-body will be the following json_encoded array:
[
[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
]
That mainly is the array that monolog passes to the handlers…