diff --git a/lib/Logging/LogHandler.php b/lib/Logging/LogHandler.php index 47d183ab33..4092bb40e3 100644 --- a/lib/Logging/LogHandler.php +++ b/lib/Logging/LogHandler.php @@ -19,18 +19,12 @@ class LogHandler extends AbstractProcessingHandler { */ const DAYS_TO_KEEP_LOGS = 30; - /** @var callable */ + /** @var callable|null */ private $rand_function; public function __construct($level = \MailPoetVendor\Monolog\Logger::DEBUG, $bubble = \true, $rand_function = null) { parent::__construct($level, $bubble); - if (!$rand_function) { - $this->rand_function = function($min, $max) { - return rand($min, $max); - }; - } else { - $this->rand_function = $rand_function; - } + $this->rand_function = $rand_function; } protected function write(array $record) { @@ -53,7 +47,10 @@ class LogHandler extends AbstractProcessingHandler { } private function getRandom() { - return call_user_func($this->rand_function, 0, 100); + if ($this->rand_function) { + return call_user_func($this->rand_function, 0, 100); + } + return rand(0, 100); } private function purgeOldLogs() {