From 6f2ca84ecacbfd72e7513f9b06f3dfd41eb1ade2 Mon Sep 17 00:00:00 2001
From: moshe weitzman <weitzman@cyrve.com>
Date: Thu, 9 Oct 2008 03:07:52 +0000
Subject: [PATCH] Add ability to log to filesystem.

---
 devel.module | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/devel.module b/devel.module
index 2ad5094e..07e013ed 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()
  */
-- 
GitLab