You are here

protected function Notify::addLogger in Backup and Migrate 8.4

add our stash logger to the service locator to capture all logged messages.

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

File

lib/backup_migrate_core/src/Filter/Notify.php, line 78

Class

Notify
Class Notify

Namespace

BackupMigrate\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);
}