protected function FileLog::render in File Log 8
Same name and namespace in other branches
- 2.0.x src/Logger/FileLog.php \Drupal\filelog\Logger\FileLog::render()
Renders a message to a string.
Parameters
mixed $level: Severity level of the log message.
string $message: Content of the log message.
array $context: Context of the log message.
Return value
string The formatted message.
1 call to FileLog::render()
- FileLog::log in src/
Logger/ FileLog.php - Logs with an arbitrary level.
File
- src/
Logger/ FileLog.php, line 213
Class
- FileLog
- File-based logger.
Namespace
Drupal\filelog\LoggerCode
protected function render($level, $message, array $context = []) : string {
// Populate the message placeholders.
$variables = $this->parser
->parseMessagePlaceholders($message, $context);
// Pass in bubbleable metadata that are just discarded later to prevent a
// LogicException due to too early rendering. The metadata of the string
// is not needed as it is not used for cacheable output but for writing to a
// logfile.
$bubbleable_metadata_to_discard = new BubbleableMetadata();
$log = new LogMessage($level, $message, $variables, $context);
$entry = $this->token
->replace($this->config
->get('format'), [
'log' => $log,
], [], $bubbleable_metadata_to_discard);
return PlainTextOutput::renderFromHtml($entry);
}