public function SecurityReview::logCheckResult in Security Review 8
Logs a check result.
Parameters
\Drupal\security_review\CheckResult $result: The result to log.
File
- src/
SecurityReview.php, line 212
Class
- SecurityReview
- A class containing static methods regarding the module's configuration.
Namespace
Drupal\security_reviewCode
public function logCheckResult(CheckResult $result = NULL) {
if ($this
->isLogging()) {
if ($result == NULL) {
$check = $result
->check();
$context = [
'@check' => $check
->getTitle(),
'@namespace' => $check
->getNamespace(),
];
$this
->log($check, '@check of @namespace produced a null result', $context, RfcLogLevel::CRITICAL);
return;
}
$check = $result
->check();
// Fallback log message.
$level = RfcLogLevel::NOTICE;
$message = '@name check invalid result';
// Set log message and level according to result.
switch ($result
->result()) {
case CheckResult::SUCCESS:
$level = RfcLogLevel::INFO;
$message = '@name check succeeded';
break;
case CheckResult::FAIL:
$level = RfcLogLevel::ERROR;
$message = '@name check failed';
break;
case CheckResult::WARN:
$level = RfcLogLevel::WARNING;
$message = '@name check raised a warning';
break;
case CheckResult::INFO:
$level = RfcLogLevel::INFO;
$message = '@name check returned info';
break;
}
$context = [
'@name' => $check
->getTitle(),
];
$this
->log($check, $message, $context, $level);
}
}