Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Fallback to messagequeue on failure #2948

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 24 additions & 1 deletion libraries/joomla/log/log.php
Expand Up @@ -252,7 +252,30 @@ protected function addLogEntry(JLogEntry $entry)

if (class_exists($class))
{
$this->loggers[$signature] = new $class($this->configurations[$signature]);
$logOptions = $this->configurations[$signature];
// Logs can fail, this should not cause Joomla! to faile
try
{
$logger = new $class($logOptions);
}
catch (\RuntimeException $exception)
{
$logType = $logOptions['logger'];
// If the log type was the messagequeue then we are truly dead
if ( $logType == 'messagequeue')
{
throw $exception;
}

// Switch to messagequeue
$logOptions['logger'] = 'messagequeue';
$logger = new JLogLoggerMessagequeue($logOptions);
// Log the failure in the new log
$logErrorEntry = new JLogEntry('Unable to create log of type '.$logType, Jlog::ERROR);
$logger->addEntry($logErrorEntry);

}
$this->loggers[$signature] = $logger;
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions libraries/joomla/log/logger/formattedtext.php
Expand Up @@ -89,6 +89,12 @@ public function __construct(array &$options)

// Build the fields array based on the format string.
$this->parseFields();

// Make sure the log file is writable
if (!is_writable($this->path))
{
throw new RuntimeException('Cannot write to log file.');
}
}

/**
Expand Down