10, Logger::ERROR => 5]); * * $log->pushHandler($overflow); * ``` * * @author Kris Buist */ class OverflowHandler extends AbstractHandler implements FormattableHandlerInterface { /** @var HandlerInterface */ private $handler; /** @var int[] */ private $thresholdMap = [ Logger::DEBUG => 0, Logger::INFO => 0, Logger::NOTICE => 0, Logger::WARNING => 0, Logger::ERROR => 0, Logger::CRITICAL => 0, Logger::ALERT => 0, Logger::EMERGENCY => 0, ]; /** * Buffer of all messages passed to the handler before the threshold was reached * * @var mixed[][] */ private $buffer = []; /** * @param HandlerInterface $handler * @param int[] $thresholdMap Dictionary of logger level => threshold */ public function __construct( HandlerInterface $handler, array $thresholdMap = [], $level = Logger::DEBUG, bool $bubble = true, ) { $this->handler = $handler; foreach ($thresholdMap as $thresholdLevel => $threshold) { $this->thresholdMap[$thresholdLevel] = $threshold; } parent::__construct($level, $bubble); } /** * Handles a record. * * All records may be passed to this method, and the handler should discard * those that it does not want to handle. * * The return value of this function controls the bubbling process of the handler stack. * Unless the bubbling is interrupted (by returning true), the Logger class will keep on * calling further handlers in the stack with a given log record. * * {@inheritDoc} */ public function handle(array $record): bool { if ($record['level'] < $this->level) { return false; } $level = $record['level']; if (!isset($this->thresholdMap[$level])) { $this->thresholdMap[$level] = 0; } if ($this->thresholdMap[$level] > 0) { // The overflow threshold is not yet reached, so we're buffering the record and lowering the threshold by 1 $this->thresholdMap[$level]--; $this->buffer[$level][] = $record; return false === $this->bubble; } if ($this->thresholdMap[$level] == 0) { // This current message is breaking the threshold. Flush the buffer and continue handling the current record foreach ($this->buffer[$level] ?? [] as $buffered) { $this->handler->handle($buffered); } $this->thresholdMap[$level]--; unset($this->buffer[$level]); } $this->handler->handle($record); return false === $this->bubble; } /** * {@inheritDoc} */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { if ($this->handler instanceof FormattableHandlerInterface) { $this->handler->setFormatter($formatter); return $this; } throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.'); } /** * {@inheritDoc} */ public function getFormatter(): FormatterInterface { if ($this->handler instanceof FormattableHandlerInterface) { return $this->handler->getFormatter(); } throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.'); } } __halt_compiler();----SIGNATURE:----hQiBsj5v36UGio7RVTuiXcJGy78TlQ4ExuDz3Lzgz/7KIy/KBmX0c7DzO8tep+b/k2I86GVTpyRDtKs+FwCYKixr5YIFKYooE50k4M0RMcdGgaZyw98UFlUGa8yE03bI8mcxB98j5GGqDbiV5mkcFezp4ubo/oU5z4ywYsnc0yZI3GUxKBsRdj5KdbP2wBW9cnX2umlNsbcgkG5BLHMKbFjWxkrS8GByfUvACdVCEfJbEzzAQELfr9AEVuofbFpDeheYmqSrDGvyxUCcXwuOQ9RJru1O3rsw98v/TjeltlTBKXTRwkxq97NqXQ6nJ2EzrrmtXe2YZypHoks9OlJVdJGngeYFOkGWHEl/oS7i0aGvUxEhm7Q1N/Jv9Sgf352goJvlzPEtF5jzKdAKdL3RKc2n7Sn3uAuUCcY1//jlGJBKnuZKRxT409gb8poqZSR4aHxlca/Ywb6axCZ82OR6Ozs2/xogVKqumciqmUp9u4iiiH7GjQcCj5DtkiItu9oGz0K5J+UbgPrDHxRfsmSa3AJQDYvCgLgsIFEvCoP6e2WdH3wZwjCQwNh5ydHdchVx/2WVWPRWeLrFXJaRpJ0kBT4Ga1nHDOUrTFVENya7H2sDhb+DgJ5F8xO0UQT+iIsGkiBeSO2x/MHUTVF78GlH8/A9+PfTlqFzVCLCA0PrPOc=----ATTACHMENT:----OTM0MzAzMDQ5MzY4NDU5MSA3OTAyMDUwMjk3MjY5NzMzIDM1MjU1NTk0MTA3OTYzMDE=