|
1 | 1 | # Slacker-Logs |
2 | 2 | Provides interface to Slack chat from Laravel/Lumen logging. |
3 | 3 | # Installation |
4 | | -## Composer |
| 4 | +## Download |
| 5 | +### Via Composer |
5 | 6 | To install via Composer first make sure Composer is installed. |
6 | 7 | Then need to simply run the command to require the package. |
7 | 8 | `composer require exposuresoftware/slackerlogs` |
| 9 | +## Register with the Container |
| 10 | +In order to make using this package you are only required to write a very simple class and register it |
| 11 | +with your application. |
| 12 | +### Create a Provider |
| 13 | +You `Provider` class can be named whatever you wish but **must** extend the `ExposureSoftware\SlackLogs\Providers\LoggerProvider` |
| 14 | +class. |
| 15 | +This can be as simple as |
| 16 | +``` |
| 17 | +<?php |
| 18 | +
|
| 19 | +namespace App\Providers; |
| 20 | +
|
| 21 | +use ExposureSoftware\SlackLogs\Providers\LoggerProvider; |
| 22 | +
|
| 23 | +class SlackLogProvider extends LoggerProvider { |
| 24 | + protected $channel = ...; |
| 25 | + protected $user = ...; |
| 26 | + protected $hook = ...; |
| 27 | + protected $level = ...; |
| 28 | +} |
| 29 | +``` |
| 30 | +Where each of the values are set to to the values for your application. |
| 31 | +`$channel` should be the channel name you wish to direct logs to. It should include the `#` that precedes all Slack |
| 32 | +channels. |
| 33 | +`$user` is the user that the message will appear to come from. This does not have to be an actual user on your team. |
| 34 | +`$hook` is the [webhook](https://api.slack.com/incoming-webhooks) your integration will use. Please see the Slack |
| 35 | +documentation in the link regarding how to set this up and get your webhook. |
| 36 | +`$level` is an the integer value of the log level you wish to report. This and any higher log levels will be sent to |
| 37 | +Slack. See `Monolog\Logger` for these values and constants available. |
| 38 | +The available log levels are: |
| 39 | +> DEBUG = 100 |
| 40 | +> INFO = 200 |
| 41 | +> NOTICE = 250 |
| 42 | +> WARNING = 300 |
| 43 | +> ERROR = 400 |
| 44 | +> CRITICAL = 500 |
| 45 | +> ALERT = 550 |
| 46 | +> EMERGENCY = 600 |
| 47 | +### Register the Provider with the application |
| 48 | +Add the line to your providers array as follows: |
| 49 | +``` |
| 50 | +'providers' => [ |
| 51 | + ..., |
| 52 | + 'App\Providers\SlackLogProvider' |
| 53 | +}, |
| 54 | +``` |
| 55 | +Changing the fully namespaced class to the name of your `Provider`. |
0 commit comments