PHP code example of proglab / monolog-discord-handler

1. Go to this page and download the library: Download proglab/monolog-discord-handler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

proglab / monolog-discord-handler example snippets



 = new Monolog\Logger('your name');

$log->pushHandler(new DiscordHandler\DiscordHandler('https://discordapp.com/api/webhooks/xxx/yyy', 'name', 'subname', 'DEBUG'));



 = new Monolog\Logger('your name');

$log->pushHandler(new DiscordHandler\DiscordHandler([
  'https://discordapp.com/api/webhooks/xxx/yyy',
  'https://discordapp.com/api/webhooks/xxx/yyy'
], 'name', 'subname', 'DEBUG'));



 = new Monolog\Logger('name');

$handler = new DiscordHandler\DiscordHandler('https://discordapp.com/api/webhooks/xxx/yyy', 'name', 'subname', 'DEBUG');

$handler->getConfig()
    ->setMultiMsg(true)
    ->setMaxMessageLength(2000) // at least 50 characters
    ->setDatetimeFormat('Y/m/d H:i')
    ->setTemplate("{datetime} {name}: {message}");

// or you can create another Config instance and replace it:
$otherConfig = new DiscordHandler\Config();
$otherConfig->setWebHooks([
  'https://discordapp.com/api/webhooks/xxx/yyy', 
  'https://discordapp.com/api/webhooks/xxx/yyy'
]);

$handler->setConfig($otherConfig);

$log->pushHandler($handler);