You are here

protected function DebugCallGraphTrait::debug in Varnish purger 8.2

Log the caller graph using $this->logger()->debug() messages.

Parameters

string $caller: Name of the PHP method that is calling ::debug().

5 calls to DebugCallGraphTrait::debug()
ZeroConfigPurger::getResultsConcurrently in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Concurrently execute the given requests.
ZeroConfigPurger::invalidateEverything in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Invalidate the entire website.
ZeroConfigPurger::invalidateTags in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Invalidate a set of tag invalidations.
ZeroConfigPurger::invalidateUrls in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Invalidate a set of URL invalidations.
ZeroConfigPurger::invalidateWildcardUrls in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Invalidate URLs that contain the wildcard character "*".

File

src/DebugCallGraphTrait.php, line 45

Class

DebugCallGraphTrait

Namespace

Drupal\varnish_purger

Code

protected function debug($caller) {

  /** @var \Drupal\purge\Logger\LoggerChannelPartInterface $logger */
  $logger = $this
    ->logger();
  if (!$logger || !$logger
    ->isDebuggingEnabled()) {
    return;
  }

  // Generate a caller name used both in logging and call counting.
  $caller = str_replace($this
    ->getClassName(__CLASS__), '', $this
    ->getClassName($caller));

  // Define a simple closure to print with prefixed indentation.
  $log = function ($output) use ($logger) {
    $space = str_repeat('  ', count($this->debug));
    $logger
      ->debug($space . $output);
  };
  if (!in_array($caller, $this->debug)) {
    $this->debug[] = $caller;
    $log("--> {$caller}():");
  }
  else {
    unset($this->debug[array_search($caller, $this->debug)]);
    $log("      (finished)");
  }
}