46 parent::__construct();
50 if (!$this->handler instanceof
HandlerInterface && !is_callable($this->handler)) {
51 throw new \RuntimeException(
"The given handler (".json_encode($this->handler).
") is not a callable nor a Monolog\Handler\HandlerInterface object");
57 return $this->handler->isHandling($record);
60 public function handle(array $record)
62 if ($this->
isHandling($record) && mt_rand(1, $this->factor) === 1) {
65 $this->handler = call_user_func($this->handler, $record, $this);
66 if (!$this->handler instanceof HandlerInterface) {
67 throw new \RuntimeException(
"The factory callable should return a HandlerInterface");
71 if ($this->processors) {
72 foreach ($this->processors as $processor) {
73 $record = call_user_func($processor, $record);
77 $this->handler->handle($record);
Base Handler class providing the Handler structure.
isHandling(array $record)
Checks whether the given record will be handled by this handler.
handle(array $record)
Handles a record.
__construct($handler, $factor)
Interface that all Monolog Handlers must implement.