Skip to content

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

License

Notifications You must be signed in to change notification settings

Sysvale/rocketchat-monolog-handler

Repository files navigation

Rocket.chat Monolog Handler by Sysvale

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
       }
    };
  }
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages