Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shalvah/monolog-pusher
Monolog Handler for sending logs to Pusher channels
https://github.com/shalvah/monolog-pusher
error-handling logging logs monolog pusher pusher-channels
Last synced: 3 months ago
JSON representation
Monolog Handler for sending logs to Pusher channels
- Host: GitHub
- URL: https://github.com/shalvah/monolog-pusher
- Owner: shalvah
- Created: 2018-06-01T11:08:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T04:34:21.000Z (8 months ago)
- Last Synced: 2024-10-06T03:19:36.438Z (4 months ago)
- Topics: error-handling, logging, logs, monolog, pusher, pusher-channels
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# monolog-pusher
[![Build Status](https://travis-ci.com/shalvah/monolog-pusher.svg?branch=master)](https://travis-ci.com/shalvah/monolog-pusher)
[![Latest Stable Version](https://poser.pugx.org/shalvah/monolog-pusher/v/stable)](https://packagist.org/packages/shalvah/monolog-pusher)Monolog handler that sends logs to [Pusher Channels](https://pusher.com/channels).
## Installation
```bash
composer require shalvah/monolog-pusher
```## Usage
- Create a new `PusherHandler`, passing in the [Pusher constructor options](https://github.com/pusher/pusher-http-php#pusher-channels-constructor) as an array:```php
$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:
```php
$pusher = new \Pusher\Pusher();
$handler = new \Shalvah\MonologPusher\PusherHandler($pusher);
```- Attach the handler to your Monolog logger:
```php
$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 your `Logger` (in the above example, "pusher-logs"). The name of the event will be *`log`*:
```php
$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:
```php
$handler = new \Shalvah\MonologPusher\PusherHandler($config, \Monolog\Logger::DEBUG);
```