You are here

public function DrupalSetMessageLogger::log in Backup and Migrate 8.4

Logs with an arbitrary level.

Parameters

mixed $level:

string $message:

array $context:

Return value

null

File

src/Environment/DrupalSetMessageLogger.php, line 27

Class

DrupalSetMessageLogger
Class DrupalLogger.

Namespace

BackupMigrate\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_set_message($message, $type, FALSE);
}