You are here

public function DrupalSetMessageLogger::log in Backup and Migrate 5.0.x

Logs with an arbitrary level.

Parameters

mixed $level:

string $message:

array $context:

File

src/Drupal/Environment/DrupalSetMessageLogger.php, line 22

Class

DrupalSetMessageLogger
Sends messages to the browser when B&M Migrate is run in interactive mode.

Namespace

Drupal\backup_migrate\Drupal\Environment

Code

public function log($level, $message, array $context = []) {

  // Translate the PSR logging level to a drupal message type.
  switch ($level) {
    case LogLevel::EMERGENCY:
    case LogLevel::ALERT:
    case LogLevel::CRITICAL:
    case LogLevel::ERROR:
      $type = 'error';
      break;
    case LogLevel::WARNING:
    case LogLevel::NOTICE:
      $type = 'warning';
      break;
    default:
      $type = 'status';
      break;
  }

  // @todo Handle translations properly.
  \Drupal::messenger()
    ->addMessage($message, $type, FALSE);
}