You are here

protected function Notify::addLogger in Backup and Migrate 5.0.x

Add the stash logger to the service locator to capture all logged messages.

2 calls to Notify::addLogger()
Notify::beforeBackup in src/Core/Filter/Notify.php
Notify::beforeRestore in src/Core/Filter/Notify.php

File

src/Core/Filter/Notify.php, line 95

Class

Notify
Notifies by email when a backup succeeds or fails.

Namespace

Drupal\backup_migrate\Core\Filter

Code

protected function addLogger() {
  $services = $this
    ->plugins()
    ->services();

  // Get the current logger.
  $logger = $services
    ->get('Logger');

  // Create a new stash logger to save messages.
  $this->logstash = new StashLogger();

  // Add a tee to send logs to both the regular logger and our stash.
  $services
    ->add('Logger', new TeeLogger([
    $logger,
    $this->logstash,
  ]));

  // Add the services back into the plugin manager to re-inject existing
  // plugins.
  $this
    ->plugins()
    ->setServiceLocator($services);
}