You are here

function drupal_debug in Devel 7

Same name and namespace in other branches
  1. 5 devel.module \drupal_debug()
  2. 6 devel.module \drupal_debug()

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

Parameters

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

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

Return value

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

See also

dd()

http://drupal.org/node/314112

1 call to drupal_debug()
devel.module in ./devel.module
This module holds functions useful for Drupal development.

File

./devel.module, line 1877
This module holds functions useful for Drupal development.

Code

function drupal_debug($data, $label = NULL) {
  $out = ($label ? $label . ': ' : '') . print_r($data, TRUE) . "\n";

  // The temp directory does vary across multiple simpletest instances.
  $file = file_directory_temp() . '/drupal_debug.txt';
  if (file_put_contents($file, $out, FILE_APPEND) === FALSE) {
    drupal_set_message(t('Devel was unable to write to %file.', array(
      '%file' => $file,
    )), 'error');
    return FALSE;
  }
}