You are here

function debug in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/includes/common.inc \debug()

Outputs debug information.

The debug information is passed on to trigger_error() after being converted to a string using _drupal_debug_message().

Parameters

$data: Data to be output.

$label: Label to prefix the data.

$print_r: Flag to switch between print_r() and var_export() for data conversion to string. Set $print_r to FALSE to use var_export() instead of print_r(). Passing recursive data structures to var_export() will generate an error.

13 calls to debug()
AssertPageCacheContextsAndTagsTrait::assertCacheContexts in core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
Ensures that some cache contexts are present in the current response.
AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge in core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
Asserts the max age header.
AssertPageCacheContextsAndTagsTrait::debugCacheTags in core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
Provides debug information for cache tags.
EntityCacheTagsTestBase::verifyRenderCache in core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
Verify that a given render cache entry exists, with the correct cache tags.
FieldPluginBase::addAdditionalFields in core/modules/views/src/Plugin/views/field/FieldPluginBase.php
Add 'additional' fields to the query.

... See full list

11 string references to 'debug'
ConfigInstallProfileUnmetDependenciesTest::error in core/modules/config/src/Tests/ConfigInstallProfileUnmetDependenciesTest.php
Override the error method so we can test for the expected exception.
ErrorTest::providerTestGetLastCaller in core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
Data provider for testGetLastCaller.
ProgressBar::determineBestFormat in vendor/symfony/console/Helper/ProgressBar.php
ProgressBarTest::provideFormat in vendor/symfony/console/Tests/Helper/ProgressBarTest.php
Provides each defined format.
RouterTest::testSetOptionsWithSupportedOptions in vendor/symfony/routing/Tests/RouterTest.php

... See full list

File

core/includes/common.inc, line 1179
Common functions that many Drupal modules will need to reference.

Code

function debug($data, $label = NULL, $print_r = TRUE) {

  // Print $data contents to string.
  $string = Html::escape($print_r ? print_r($data, TRUE) : var_export($data, TRUE));

  // Display values with pre-formatting to increase readability.
  $string = '<pre>' . $string . '</pre>';
  trigger_error(trim($label ? "{$label}: {$string}" : $string));
}