public function DrupalHandler::write in Monolog 8
Same name and namespace in other branches
- 2.x src/Logger/Handler/DrupalHandler.php \Drupal\monolog\Logger\Handler\DrupalHandler::write()
File
- src/
Logger/ Handler/ DrupalHandler.php, line 44
Class
- DrupalHandler
- Forwards logs to a Drupal logger.
Namespace
Drupal\monolog\Logger\HandlerCode
public function write(array $record) {
// Set up context with the data Drupal loggers expect.
// @see Drupal\Core\Logger\LoggerChannel::log()
$context = $record['context'] + [
'channel' => $record['channel'],
'link' => '',
'user' => isset($record['extra']['user']) ? $record['extra']['user'] : NULL,
'uid' => isset($record['extra']['uid']) ? $record['extra']['uid'] : 0,
'request_uri' => isset($record['extra']['request_uri']) ? $record['extra']['request_uri'] : '',
'referer' => isset($record['extra']['referer']) ? $record['extra']['referer'] : '',
'ip' => isset($record['extra']['ip']) ? $record['extra']['ip'] : 0,
'timestamp' => $record['datetime']
->format('U'),
];
$level = static::$levels[$record['level']];
$this->logger
->log($level, $record['message'], $context);
}