sysvale/rocketchat-monolog-handler

A Rocket.chat Monolog Handler meant to be used in Laravel projects developed by Sysvale Softgroup

v1.2.1 2022-10-13 01:12 UTC

This package is auto-updated.

Last update: 2024-11-13 05:26:25 UTC


README

Monolog Handler CI

Monolog Handler para ser usado em projetos Laravel. Adaptado da implementação para Slack.

Inspirado nos seguintes projetos:

Instalação

composer require sysvale/rocketchat-monolog-handler

Uso

Importe a seguinte classe no seu config/logging.php

use Sysvale\Logging\RocketChatHandler;

Adicione o código abaixo ao Array de channels no arquivo logging.php

'rocketchat' => [
    'driver' => 'monolog',
    'handler' => RocketChatHandler::class,
    'with' => [
        'webhooks' => [env('ROCKET_CHAT_WEBHOOK', '')],
        'username' => 'Awesome Laravel Bot',
        'emoji' => ':rotating_light:',
    ],
    'level' => 'warning',
],

Atualize o canal stack de:

'channels' => ['daily'],

para:

'channels' => ['daily', 'rocketchat'],

Lembre-se de adicionar as variáveis de ambiente

ROCKET_CHAT_WEBHOOK=

Configure um WebHook no seu servidor do Rocket.Chat

Você pode utilizar o seguinte script:

/* exported Script */
/* globals console, _, s */

/** Global Helpers
 *
 * console - A normal console instance
 * _       - An underscore instance
 * s       - An underscore string instance
 */

class Script {
  /**
   * @params {object} request
   */
  process_incoming_request({ request }) {

    // console is a global helper to improve debug
    console.log(request);

    return {
      content:{
        text: request.content.text,
        username: request.content.username,
        emoji: request.content.emoji,
        attachments: request.content.attachments
       }
    };
  }
}