| @@ 33-65 (lines=33) @@ | ||
| 30 | * @param Container $dic [description] |
|
| 31 | * @return void |
|
| 32 | */ |
|
| 33 | public function register(Container $dic) |
|
| 34 | { |
|
| 35 | // Do nothing when no loglevel is set |
|
| 36 | if (empty($this->loglevel)) { |
|
| 37 | return; |
|
| 38 | } |
|
| 39 | ||
| 40 | // Make sure there's a 'Monolog.Handlers' service |
|
| 41 | if (!$dic->offsetExists('Monolog.Handlers')) : |
|
| 42 | $dic['Monolog.Handlers'] = function ($dic) { |
|
| 43 | return array(); |
|
| 44 | }; |
|
| 45 | endif; |
|
| 46 | ||
| 47 | ||
| 48 | /** |
|
| 49 | * @return array |
|
| 50 | */ |
|
| 51 | $dic->extend('Monolog.Handlers', function (array $handlers, $dic) { |
|
| 52 | $handlers[] = $dic['Monolog.Handlers.BrowserConsoleHandler']; |
|
| 53 | return $handlers; |
|
| 54 | }); |
|
| 55 | ||
| 56 | ||
| 57 | ||
| 58 | /** |
|
| 59 | * @return BrowserConsoleHandler |
|
| 60 | */ |
|
| 61 | $dic['Monolog.Handlers.BrowserConsoleHandler'] = function ($dic) { |
|
| 62 | $th = new BrowserConsoleHandler($this->loglevel); |
|
| 63 | return $th; |
|
| 64 | }; |
|
| 65 | } |
|
| 66 | } |
|
| 67 | ||
| @@ 39-76 (lines=38) @@ | ||
| 36 | * @param Container $dic [description] |
|
| 37 | * @return void |
|
| 38 | */ |
|
| 39 | public function register(Container $dic) |
|
| 40 | { |
|
| 41 | ||
| 42 | // Do nothing when no incoming_webook_url is set |
|
| 43 | if (empty($this->incoming_webook_url)) { |
|
| 44 | return; |
|
| 45 | } |
|
| 46 | ||
| 47 | ||
| 48 | // Make sure there's a 'Monolog.Handlers' service |
|
| 49 | if (!$dic->offsetExists('Monolog.Handlers')) : |
|
| 50 | $dic['Monolog.Handlers'] = function ($dic) { |
|
| 51 | return array(); |
|
| 52 | }; |
|
| 53 | endif; |
|
| 54 | ||
| 55 | ||
| 56 | /** |
|
| 57 | * @return array |
|
| 58 | */ |
|
| 59 | $dic->extend('Monolog.Handlers', function (array $handlers, $dic) { |
|
| 60 | $handlers[] = $dic['Monolog.Handlers.TeamsHandler']; |
|
| 61 | return $handlers; |
|
| 62 | }); |
|
| 63 | ||
| 64 | ||
| 65 | ||
| 66 | /** |
|
| 67 | * Send log messages to Microsoft Teams. |
|
| 68 | * |
|
| 69 | * @return SlackHandler |
|
| 70 | */ |
|
| 71 | $dic['Monolog.Handlers.TeamsHandler'] = function ($dic) { |
|
| 72 | $th = new HtmlFormattedTeamsLogHandler($this->incoming_webook_url, $this->loglevel); |
|
| 73 | $th->setFormatter(new HtmlFormatter); |
|
| 74 | return $th; |
|
| 75 | }; |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||