You are here

class DrupalSetMessageLogger in Backup and Migrate 5.0.x

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

@package Drupal\backup_migrate\Drupal\Environment

Hierarchy

Expanded class hierarchy of DrupalSetMessageLogger

1 file declares its use of DrupalSetMessageLogger
backup_migrate.module in ./backup_migrate.module
Primary hook implementations for Backup Migrate.

File

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

Namespace

Drupal\backup_migrate\Drupal\Environment
View source
class DrupalSetMessageLogger extends AbstractLogger {

  /**
   * Logs with an arbitrary level.
   *
   * @param mixed $level
   * @param string $message
   * @param array $context
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalSetMessageLogger::log public function Logs with an arbitrary level.