PHP code example of middlewares / reporting-logger

1. Go to this page and download the library: Download middlewares/reporting-logger 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/ */

    

middlewares / reporting-logger example snippets


Dispatcher::run([
    new Middlewares\JsonPayload(),
    new Middlewares\ReportingLogger($logger)
]);

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('access');
$logger->pushHandler(new StreamHandler('data/logs.txt'));

Dispatcher::run([
    new Middlewares\ReportingLogger($logger)
]);

$responseFactory = new MyOwnResponseFactory();

$reporting = new Middlewares\ReportingLogger($logger, $responseFactory);

// In back-end: configure to collect all reportings send to the same path
$reporting = (new Middlewares\ReportingLogger($logger))->path('/log-reporting')

$reporting = (new Middlewares\ReportingLogger($logger))
    ->message('New error: "%{message}" in line %{lineNumber}, column %{colNumber}')
]);