mirror of
https://github.com/Seldaek/monolog.git
synced 2025-02-24 06:52:34 +01:00
Move handler checks in constructor
This commit is contained in:
parent
18bfe94053
commit
9b350bb1fd
@ -55,6 +55,10 @@ class FilterHandler extends AbstractHandler
|
|||||||
$this->handler = $handler;
|
$this->handler = $handler;
|
||||||
$this->bubble = $bubble;
|
$this->bubble = $bubble;
|
||||||
$this->setAcceptedLevels($minLevelOrList, $maxLevel);
|
$this->setAcceptedLevels($minLevelOrList, $maxLevel);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,12 +106,6 @@ class FilterHandler extends AbstractHandler
|
|||||||
|
|
||||||
// The same logic as in FingersCrossedHandler
|
// The same logic as in FingersCrossedHandler
|
||||||
if (!$this->handler instanceof HandlerInterface) {
|
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);
|
$this->handler = call_user_func($this->handler, $record, $this);
|
||||||
if (!$this->handler instanceof HandlerInterface) {
|
if (!$this->handler instanceof HandlerInterface) {
|
||||||
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
||||||
|
@ -62,6 +62,10 @@ class FingersCrossedHandler extends AbstractHandler
|
|||||||
$this->bubble = $bubble;
|
$this->bubble = $bubble;
|
||||||
$this->stopBuffering = $stopBuffering;
|
$this->stopBuffering = $stopBuffering;
|
||||||
$this->passthruLevel = $passthruLevel;
|
$this->passthruLevel = $passthruLevel;
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,9 +97,6 @@ class FingersCrossedHandler extends AbstractHandler
|
|||||||
$this->buffering = false;
|
$this->buffering = false;
|
||||||
}
|
}
|
||||||
if (!$this->handler instanceof HandlerInterface) {
|
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);
|
$this->handler = call_user_func($this->handler, $record, $this);
|
||||||
if (!$this->handler instanceof HandlerInterface) {
|
if (!$this->handler instanceof HandlerInterface) {
|
||||||
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
||||||
|
@ -48,6 +48,10 @@ class SamplingHandler extends AbstractHandler
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->handler = $handler;
|
$this->handler = $handler;
|
||||||
$this->factor = $factor;
|
$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)
|
public function isHandling(array $record)
|
||||||
@ -60,12 +64,6 @@ class SamplingHandler extends AbstractHandler
|
|||||||
if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) {
|
if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) {
|
||||||
// The same logic as in FingersCrossedHandler
|
// The same logic as in FingersCrossedHandler
|
||||||
if (!$this->handler instanceof HandlerInterface) {
|
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);
|
$this->handler = call_user_func($this->handler, $record, $this);
|
||||||
if (!$this->handler instanceof HandlerInterface) {
|
if (!$this->handler instanceof HandlerInterface) {
|
||||||
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user