You are here

public function MessagePlaceholderProcessor::__invoke in Monolog 2.x

Same name and namespace in other branches
  1. 8 src/Logger/Processor/MessagePlaceholderProcessor.php \Drupal\monolog\Logger\Processor\MessagePlaceholderProcessor::__invoke()

File

src/Logger/Processor/MessagePlaceholderProcessor.php, line 32

Class

MessagePlaceholderProcessor
Parse and replace message placeholders.

Namespace

Drupal\monolog\Logger\Processor

Code

public function __invoke(array $record) {

  // Populate the message placeholders and then replace them in the message.
  $message_placeholders = $this->parser
    ->parseMessagePlaceholders($record['message'], $record['context']);
  $record['message'] = empty($message_placeholders) ? $record['message'] : strtr($record['message'], $message_placeholders);

  // Remove the replaced placeholders from the context to prevent logging the
  // same information twice.
  foreach (array_keys($message_placeholders) as $placeholder) {
    unset($record['context'][$placeholder]);
  }
  return $record;
}