/**
* Method to add an entry to the appropriate loggers.
*
* @param LogEntry $entry The LogEntry object to send to the loggers.
*
* @return void
*
* @since 1.7.0
* @throws \RuntimeException
*/
protected function addLogEntry(LogEntry $entry)
{
// Find all the appropriate loggers based on priority and category for the entry.
$loggers = $this->findLoggers($entry->priority, $entry->category);
foreach ((array) $loggers as $signature) {
// Attempt to instantiate the logger object if it doesn't already exist.
if (empty($this->loggers[$signature])) {
if ($this->loggerRegistry->hasLogger($this->configurations[$signature]['logger'])) {
$class = $this->loggerRegistry->getLoggerClass($this->configurations[$signature]['logger']);
} else {
@trigger_error(sprintf('Attempting to automatically resolve loggers to the %s namespace is deprecated as of 4.0 and will be removed in 5.0.' . ' Use the logger registry instead.', __NAMESPACE__), E_USER_DEPRECATED);
$class = __NAMESPACE__ . '\\Logger\\' . ucfirst($this->configurations[$signature]['logger']) . 'Logger';
if (!class_exists($class)) {
throw new \RuntimeException('Unable to create a Logger instance: ' . $class);
}
}
$this->loggers[$signature] = new $class($this->configurations[$signature]);
}
// Add the entry to the logger.
$this->loggers[$signature]->addEntry(clone $entry);
}
}