| 1 |
<?php |
| 2 |
|
| 3 |
namespace Shellbox; |
| 4 |
|
| 5 |
use Monolog\Handler\AbstractHandler; |
| 6 |
|
| 7 |
class ClientLogHandler extends AbstractHandler { |
| 8 |
/** @var array */ |
| 9 |
private $records = []; |
| 10 |
|
| 11 |
public function handle( array $record ): bool { |
| 12 |
$this->records[] = [ |
| 13 |
'level' => $record['level'], |
| 14 |
'message' => $record['message'], |
| 15 |
'context' => $record['context'] |
| 16 |
]; |
| 17 |
return false; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Remove and return the accumulated log entries |
| 22 |
* |
| 23 |
* @return array |
| 24 |
*/ |
| 25 |
public function flush() { |
| 26 |
$records = $this->records; |
| 27 |
$this->records = []; |
| 28 |
return $records; |
| 29 |
} |
| 30 |
} |