You are here

public function DevelDumperManager::debug in Devel 8.3

Same name and namespace in other branches
  1. 8 src/DevelDumperManager.php \Drupal\devel\DevelDumperManager::debug()
  2. 8.2 src/DevelDumperManager.php \Drupal\devel\DevelDumperManager::debug()
  3. 4.x src/DevelDumperManager.php \Drupal\devel\DevelDumperManager::debug()

Logs a variable to a drupal_debug.txt in the site's temp directory.

Parameters

mixed $input: The variable to log to the drupal_debug.txt log file.

string $name: (optional) If set, a label to output before $data in the log file.

string $plugin_id: (optional) The plugin ID, defaults to NULL.

Return value

void|false Empty if successful, FALSE if the log file could not be written.

Overrides DevelDumperManagerInterface::debug

See also

dd()

http://drupal.org/node/314112

File

src/DevelDumperManager.php, line 104

Class

DevelDumperManager
Class DevelDumperManager.

Namespace

Drupal\devel

Code

public function debug($input, $name = NULL, $plugin_id = NULL) {
  $output = $this
    ->createInstance($plugin_id)
    ->export($input, $name) . "\n";

  // The temp directory does vary across multiple simpletest instances.
  $file = $this->config
    ->get('debug_logfile');
  if (file_put_contents($file, $output, FILE_APPEND) === FALSE && $this
    ->hasAccessToDevelInformation()) {
    $this
      ->messenger()
      ->addError($this
      ->t('Devel was unable to write to %file.', [
      '%file' => $file,
    ]));
    return FALSE;
  }
}