PHP code example of creitive / monolog-extra-data-processor

1. Go to this page and download the library: Download creitive/monolog-extra-data-processor 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/ */

    

creitive / monolog-extra-data-processor example snippets


$app->configureMonologUsing(function(\Monolog\Logger $monolog) use ($app)
{
    $configurator = new \App\Log\Configurator;

    $configurator->configure($monolog, $app);
});
 php
$extraDataProcessor = new ExtraDataProcessor([
    'environment' => getenv('APP_ENV'),
    'cookies' => $_COOKIES,
    'foo' => 'bar',
]);

/*
 * Assuming `$monolog` is an instance of `\Monolog\Logger`:
 */
$monolog->pushProcessor($extraDataProcessor);
 php
$extraDataProcessor = addExtraData([
    'baz' => 'qux',
]);
 php
$extraDataProcessor->removeExtraData([
    'foo',
    'baz',
]);
 php
$extraData = $extraDataProcessor->getExtraData();