From f820b6edcd3b2b22d64aef71b2750253d2bcafcd Mon Sep 17 00:00:00 2001 From: nickw Date: Mon, 19 Oct 2009 17:15:35 +0000 Subject: Adding debug options to admin site settings. Debugging errors and warnings to screen. If notice level is enabled, output is sent to system log file. git-svn-id: http://code.elgg.org/elgg/trunk@3563 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 36e87eca9..a77922a9f 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1752,23 +1752,26 @@ function elgg_log($message, $level='NOTICE') { // only log when debugging is enabled if (isset($CONFIG->debug)) { + // debug to screen or log? + $to_screen = !($CONFIG->debug == 'NOTICE'); + switch ($level) { case 'DEBUG': case 'ERROR': // always report - elgg_dump("$level: $message"); + elgg_dump("$level: $message", $to_screen); break; case 'WARNING': // report execept if user wants only errors - if ($config->debug != 'ERROR') { - elgg_dump("$level: $message"); + if ($CONFIG->debug != 'ERROR') { + elgg_dump("$level: $message", $to_screen); } break; case 'NOTICE': default: // only report when lowest level is desired - if ($config->debug == 'NOTICE') { - elgg_dump("$level: $message"); + if ($CONFIG->debug == 'NOTICE') { + elgg_dump("$level: $message", FALSE); } break; } @@ -1783,14 +1786,23 @@ function elgg_log($message, $level='NOTICE') { * Extremely generic var_dump-esque wrapper * * Immediately dumps the given $value to the screen as a human-readable string. + * The $value can instead be written to the system log through the use of the + * $to_screen flag. * * @param mixed $value + * @param bool $to_screen * @return void */ -function elgg_dump($value) { - echo '
';
-	print_r($value);
-	echo '
'; +function elgg_dump($value, $to_screen = TRUE) { + if ($to_screen == TRUE) { + echo '
';
+		print_r($value);
+		echo '
'; + } + else + { + error_log($value); + } } /** -- cgit v1.2.3