PHP code example of yapro / monolog-ext

1. Go to this page and download the library: Download yapro/monolog-ext 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/ */

    

yapro / monolog-ext example snippets


$logger->info('I just got the logger');
$logger->error('An error occurred');

$logger->warning('My warning', array(
   'my' => 'data',
   'exception' => $e,// now you can see the above written custom stack trace as a string
));
$logger->warning('My second warning', array($e));// the short variant of version which you can see the above

$logger->error('An error occurred', [ 'my mixed type var' => (new VarHelper)->dump($myVar, 5) ] );

throw (new ExtraException())->setExtra('mixed data');



use Monolog\Logger;
use YaPro\MonologExt\Handler\WiseHandler;

$logger = new Logger('app');
$logger->pushHandler(new WiseHandler());

$logger->error('Payment error', ['order_id' => 42]);



use YaPro\MonologExt\PrudentErrorHandler;

new PrudentErrorHandler($logger);