You are here

public function CacheLogger::load in Ultimate Cron 8.2

Load a log.

Parameters

string $name: Name of log.

string $lock_id: Specific lock id.

Return value

\Drupal\ultimate_cron\Logger\LogEntry Log entry

Overrides LoggerInterface::load

1 call to CacheLogger::load()
CacheLogger::getLogEntries in src/Plugin/ultimate_cron/Logger/CacheLogger.php
Get page with log entries for a job.

File

src/Plugin/ultimate_cron/Logger/CacheLogger.php, line 58

Class

CacheLogger
Cache Logger.

Namespace

Drupal\ultimate_cron\Plugin\ultimate_cron\Logger

Code

public function load($name, $lock_id = NULL, array $log_types = [
  ULTIMATE_CRON_LOG_TYPE_NORMAL,
]) {
  $log_entry = new LogEntry($name, $this);
  if (!$lock_id) {
    $cache = $this->cache
      ->get('uc-name:' . $name, TRUE);
    if (empty($cache) || empty($cache->data)) {
      return $log_entry;
    }
    $lock_id = $cache->data;
  }
  $cache = $this->cache
    ->get('uc-lid:' . $lock_id, TRUE);
  if (!empty($cache->data)) {
    $log_entry
      ->setData((array) $cache->data);
    $log_entry->finished = TRUE;
  }
  return $log_entry;
}