You are here

protected function DebugCallGraphTrait::logDebugTable in Varnish purger 8.2

Render debugging information as table to $this->logger()->debug().

Parameters

mixed[] $table: Associative array with each key being the row title. Each value can be a string, or when it is a array itself, the row will be repeated.

int $left: Amount of characters that the left size of the table can be long.

2 calls to DebugCallGraphTrait::logDebugTable()
DebugCallGraphTrait::logFailedRequest in src/DebugCallGraphTrait.php
Write an error to the log for a failed request.
ZeroConfigPurger::getResultsConcurrently in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Concurrently execute the given requests.

File

src/DebugCallGraphTrait.php, line 129

Class

DebugCallGraphTrait

Namespace

Drupal\varnish_purger

Code

protected function logDebugTable(array $table, $left = 15) {
  $longest_key = max(array_map('strlen', array_keys($table)));
  $logger = $this
    ->logger();
  if ($longest_key > $left) {
    $left = $longest_key;
  }
  foreach ($table as $title => $value) {
    $spacing = str_repeat(' ', $left - strlen($title));
    $title = strtoupper($title) . $spacing . ' | ';
    if (is_array($value)) {
      foreach ($value as $repeated_value) {
        $logger
          ->debug($title . $repeated_value);
      }
    }
    else {
      $logger
        ->debug($title . $value);
    }
  }
}