public function ErrorLog::log in Error Log 8
Overrides RfcLoggerTrait::log
File
- src/
Logger/ ErrorLog.php, line 76
Class
- ErrorLog
- Logs events to the PHP error log.
Namespace
Drupal\error_log\LoggerCode
public function log($level, $message, array $context = []) {
if (empty($this->config
->get('log_levels')["level_{$level}"])) {
return;
}
if (in_array($context['channel'], $this->config
->get('ignored_channels') ?: [])) {
return;
}
// Drush handles error logging for us, so disable redundant logging.
if (function_exists('drush_main') && !ini_get('error_log')) {
return;
}
$level = static::LOG_LEVELS[$level];
$message_placeholders = $this->parser
->parseMessagePlaceholders($message, $context);
$message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
$message = "[{$level}] [{$context['channel']}] [{$context['ip']}] [uid:{$context['uid']}] [{$context['request_uri']}] [{$context['referer']}] {$message}";
error_log($message);
}