shalvah / monolog-pusher
Monolog handler for sending logs to Pusher
Installs: 23 024
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: >= 7.2
- monolog/monolog: ^2.0
- pusher/pusher-php-server: ^4.0 | ^5.0 | ^6.0
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ^7.2
This package is auto-updated.
Last update: 2024-11-18 05:26:02 UTC
README
Monolog handler that sends logs to Pusher Channels.
Installation
composer require shalvah/monolog-pusher
Usage
- Create a new
PusherHandler
, passing in the Pusher constructor options as an array:
$config = ['YOUR_APP_KEY', 'YOUR_APP_SECRET', 'YOUR_APP_ID', ['cluster' => 'YOUR_APP_CLUSTER']]; $handler = new \Shalvah\MonologPusher\PusherHandler($config);
- Alternatively, if you've already got an existing
Pusher
instance, you can pass that to the handler:
$pusher = new \Pusher\Pusher(); $handler = new \Shalvah\MonologPusher\PusherHandler($pusher);
- Attach the handler to your Monolog logger:
$logger = new \Monolog\Logger('pusher-logs'); $logger->pushHandler($handler);
- Now you can call the various log methods (
info
,error
,debug
and so forth) on your logger to send a log message to Pusher. The name of the Pusher channel used will be the name you set when creating yourLogger
(in the above example, "pusher-logs"). The name of the event will belog
:
$logger->error('oops!');
By default, the PusherHandler
will only log messages of level error and above. You can change this by passing a minimum level as a second parameter to the constructor:
$handler = new \Shalvah\MonologPusher\PusherHandler($config, \Monolog\Logger::DEBUG);