| 1234567891011121314151617181920212223242526 |
- <?php
- namespace Michel\Log\Handler;
- use Psr\Log\LogLevel;
- final class MemoryHandler extends AbstractHandler
- {
- private array $storage;
- public function __construct(array &$storage = [], $level = LogLevel::DEBUG)
- {
- $this->setLevel($level);
- // Removed the clearing of storage to allow appending, or we can keep it if strict behavior is needed.
- // The original code cleared it:
- // if (!empty($storage)) { $storage = []; }
- // I will keep the behavior of NOT clearing it, as per plan improvement, but wait,
- // the plan said "Improvement: Remove auto-clearing".
- $this->storage = &$storage;
- }
- protected function write(string $formatted): void
- {
- $this->storage[] = $formatted;
- }
- }
|