summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormoshe weitzman2008-10-09 03:07:52 (GMT)
committermoshe weitzman2008-10-09 03:07:52 (GMT)
commit6f2ca84ecacbfd72e7513f9b06f3dfd41eb1ade2 (patch)
tree26b5a473c564c5b7a8830aa88ff566244870511a
parenta921952b92d549d4dab6e3e966e2de21adf6bdba (diff)
Add ability to log to filesystem.6.x-1.12
-rw-r--r--devel.module27
1 files changed, 27 insertions, 0 deletions
diff --git a/devel.module b/devel.module
index 2ad5094..07e013e 100644
--- a/devel.module
+++ b/devel.module
@@ -1480,6 +1480,33 @@ function dargs($always = TRUE) {
}
}
+// An alias for drupal_debug().
+function dd($data, $label = NULL) {
+ return drupal_debug($data, $label);
+}
+
+// Log any variable to a drupal_debug.log in the site's temp directory.
+// See http://drupal.org/node/314112
+function drupal_debug($data, $label = NULL) {
+ ob_start();
+ print_r($data);
+ $string = ob_get_clean();
+ if ($label) {
+ $out = $label. ': '. $string;
+ }
+ else {
+ $out = $string;
+ }
+ $out .= "\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('The file could not be written.'), 'error');
+ return FALSE;
+ }
+}
+
/**
* Print a variable to the 'message' area of the page. Uses drupal_set_message()
*/