PHP code example of wyrihaximus / psr-3-filter
1. Go to this page and download the library: Download wyrihaximus/psr-3-filter 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/ */
wyrihaximus / psr-3-filter example snippets
$level2 = ['bad', 'evil'];
$monolog = new Monolog(); // Any PSR-3 logger
$filterredLogger = new ContextFilterLogger('level1.level2', $level2, $monolog);
$filterredLogger->info('bad', [
'level1' => [
'level2' => 'bad',
],
]); // Will reach monolog
$filterredLogger->info('good', [
'level1' => [
'level2' => 'good',
],
]); // Won't reach monolog
$filterredLogger->info('evil', [
'level1' => [
'level2' => 'evil',
],
]); // Will reach monolog
$monolog = new Monolog(); // Any PSR-3 logger
$filterredLogger = new LogLevelFilterLogger(['error'], $monolog);
$filterredLogger->error('bad'); // Won't reach monolog
$filterredLogger->info('good'); // Will reach monolog
$filterredLogger->error('evil'); // Won't reach monolog
$keywords = ['bad', 'evil'];
$monolog = new Monolog(); // Any PSR-3 logger
$filterredLogger = new MessageKeywordFilterLogger($keywords, $monolog);
$filterredLogger->info('bad'); // Won't reach monolog
$filterredLogger->info('good'); // Will reach monolog
$filterredLogger->info('evil'); // Won't reach monolog
$monolog = new Monolog(); // Any PSR-3 logger
$filterredLogger = new ContextLoggerPrefixFilterLogger($monolog);
$filterredLogger->info('bad', '[HttpServer] [Request] something gone wrong'); // Will reach monolog as: something gone wrong