You are here

StashLogger.php in Backup and Migrate 8.4

File

lib/backup_migrate_core/src/Service/StashLogger.php
View source
<?php

namespace BackupMigrate\Core\Service;

use Psr\Log\AbstractLogger;

/**
 * Saves log entries to memory to be processed during the current process.
 * This simple service does no clearing or memory management so should not be
 * used for a long-running process.
 *
 * Class StashLogger.
 *
 * @package BackupMigrate\Core\Service
 */
class StashLogger extends AbstractLogger {

  /**
   * @var array
   */
  protected $logs = [];

  /**
   * Logs with an arbitrary level.
   *
   * @param mixed $level
   * @param string $message
   * @param array $context
   *
   * @return null
   */
  public function log($level, $message, array $context = []) {
    $this->logs[] = [
      'level' => $level,
      'message' => $message,
      'context' => $context,
    ];
  }

  /**
   * Get all of the log messages that were saved to this stash.
   *
   * @return array
   */
  public function getAll() {
    return $this->logs;
  }

}

Classes

Namesort descending Description
StashLogger Saves log entries to memory to be processed during the current process. This simple service does no clearing or memory management so should not be used for a long-running process.