We will create an anonymous function to filter only record
on fake error
messages with exception
as contextual data.
CallbackFilterHandler class constructor accept an array of callback functions. Here is an example of the definition corresponding to our goal.
<?php $filters = array( function ($record) { if (!array_key_exists('exception', $record['context'])) { return false; } return (preg_match('/fake error/', $record['message']) === 1); } );