function DrupalBoot8::add_logger

8.0.x DrupalBoot8.php DrupalBoot8::add_logger()
7.x DrupalBoot8.php DrupalBoot8::add_logger()
master DrupalBoot8.php DrupalBoot8::add_logger()

File

lib/Drush/Boot/DrupalBoot8.php, line 73

Namespace

Drush\Boot

Class

DrupalBoot8

Code

function add_logger() {
  // If we're running on Drupal 8 or later, we provide a logger which will send
  // output to drush_log(). This should catch every message logged through every
  // channel.
  $container = \Drupal::getContainer();
  $parser = $container->get('logger.log_message_parser');

  $drushLogger = \Drush::logger();
  $logger = new \Drush\Log\DrushLog($parser, $drushLogger);
  $container->get('logger.factory')->addLogger($logger);
}