|
|
@@ -48,6 +48,10 @@ class SamplingHandler extends AbstractHandler
|
|
|
parent::__construct();
|
|
|
$this->handler = $handler;
|
|
|
$this->factor = $factor;
|
|
|
+
|
|
|
+ if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) {
|
|
|
+ throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function isHandling(array $record)
|
|
|
@@ -60,12 +64,6 @@ class SamplingHandler extends AbstractHandler
|
|
|
if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) {
|
|
|
// The same logic as in FingersCrossedHandler
|
|
|
if (!$this->handler instanceof HandlerInterface) {
|
|
|
- if (!is_callable($this->handler)) {
|
|
|
- throw new \RuntimeException(
|
|
|
- "The given handler (" . json_encode($this->handler)
|
|
|
- . ") is not a callable nor a Monolog\\Handler\\HandlerInterface object"
|
|
|
- );
|
|
|
- }
|
|
|
$this->handler = call_user_func($this->handler, $record, $this);
|
|
|
if (!$this->handler instanceof HandlerInterface) {
|
|
|
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|