mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 14:16:42 +02:00
Avoid calling expensive methods before checking we need to
This commit is contained in:
@@ -229,6 +229,19 @@ class Logger implements LoggerInterface
|
|||||||
$this->pushHandler(new StreamHandler('php://stderr', static::DEBUG));
|
$this->pushHandler(new StreamHandler('php://stderr', static::DEBUG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if any handler will handle this message
|
||||||
|
$handlerKey = null;
|
||||||
|
foreach ($this->handlers as $key => $handler) {
|
||||||
|
if ($handler->isHandling(array('level' => $level))) {
|
||||||
|
$handlerKey = $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// none found
|
||||||
|
if (null === $handlerKey) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!static::$timezone) {
|
if (!static::$timezone) {
|
||||||
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
|
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
|
||||||
}
|
}
|
||||||
@@ -242,18 +255,6 @@ class Logger implements LoggerInterface
|
|||||||
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone),
|
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone),
|
||||||
'extra' => array(),
|
'extra' => array(),
|
||||||
);
|
);
|
||||||
// check if any handler will handle this message
|
|
||||||
$handlerKey = null;
|
|
||||||
foreach ($this->handlers as $key => $handler) {
|
|
||||||
if ($handler->isHandling($record)) {
|
|
||||||
$handlerKey = $key;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// none found
|
|
||||||
if (null === $handlerKey) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// found at least one, process message and dispatch it
|
// found at least one, process message and dispatch it
|
||||||
foreach ($this->processors as $processor) {
|
foreach ($this->processors as $processor) {
|
||||||
|
Reference in New Issue
Block a user