diff options
author | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-19 17:15:35 +0000 |
---|---|---|
committer | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-19 17:15:35 +0000 |
commit | f820b6edcd3b2b22d64aef71b2750253d2bcafcd (patch) | |
tree | 564646570801f6e29c2dcf1f325e6ef628cc5ff8 | |
parent | 985fad83ae06027c9ba92915b6f253815e7537cc (diff) | |
download | elgg-f820b6edcd3b2b22d64aef71b2750253d2bcafcd.tar.gz elgg-f820b6edcd3b2b22d64aef71b2750253d2bcafcd.tar.bz2 |
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
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | actions/admin/site/update_basic.php | 2 | ||||
-rw-r--r-- | actions/systemsettings/install.php | 2 | ||||
-rw-r--r-- | engine/lib/elgglib.php | 30 | ||||
-rw-r--r-- | languages/en.php | 5 | ||||
-rw-r--r-- | views/default/settings/system.php | 5 | ||||
-rw-r--r-- | views/failsafe/settings/system.php | 5 |
7 files changed, 36 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index e106b5139..16f5cb4bd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,7 @@ http://code.elgg.org/elgg/..... User-visible changes: * UTF8 now saved correctly in database. #1151 * Unit tests added at engine/tests/suites.php + * Debug values output to screen when enabled in admin settings Bugfixes: * Searching by tag with extended characters now works. #1151, #1231 diff --git a/actions/admin/site/update_basic.php b/actions/admin/site/update_basic.php index 0b567340c..70cc72730 100644 --- a/actions/admin/site/update_basic.php +++ b/actions/admin/site/update_basic.php @@ -56,7 +56,7 @@ if (get_input('settings') == 'go') { $debug = get_input('debug'); if ($debug) { - set_config('debug', 1, $site->getGUID()); + set_config('debug', $debug, $site->getGUID()); } else { unset_config('debug', $site->getGUID()); } diff --git a/actions/systemsettings/install.php b/actions/systemsettings/install.php index 819ef08ee..ef606315b 100644 --- a/actions/systemsettings/install.php +++ b/actions/systemsettings/install.php @@ -62,7 +62,7 @@ if (get_input('settings') == 'go') { $debug = get_input('debug'); if ($debug) { - set_config('debug', 1, $site->getGUID()); + set_config('debug', $debug, $site->getGUID()); } else { unset_config('debug', $site->getGUID()); } 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 '<pre>'; - print_r($value); - echo '</pre>'; +function elgg_dump($value, $to_screen = TRUE) { + if ($to_screen == TRUE) { + echo '<pre>'; + print_r($value); + echo '</pre>'; + } + else + { + error_log($value); + } } /** diff --git a/languages/en.php b/languages/en.php index c93f36fd7..310f5cd09 100644 --- a/languages/en.php +++ b/languages/en.php @@ -798,7 +798,10 @@ Alternatively, you can enter your database settings below and we will try and do 'installation:sitepermissions' => "The default access permissions:", 'installation:language' => "The default language for your site:", 'installation:debug' => "Debug mode provides extra information which can be used to diagnose faults, however it can slow your system down so should only be used if you are having problems:", - 'installation:debug:label' => "Turn on debug mode", + 'installation:debug:none' => 'Turn off debug mode (recommended)', + 'installation:debug:error' => 'Display only critical errors', + 'installation:debug:warning' => 'Display errors and warnings', + 'installation:debug:notice' => 'Log all errors, warnings and notices', 'installation:httpslogin' => "Enable this to have user logins performed over HTTPS. You will need to have https enabled on your server for this to work.", 'installation:httpslogin:label' => "Enable HTTPS logins", 'installation:usage' => "This option lets Elgg send anonymous usage statistics back to Curverider.", diff --git a/views/default/settings/system.php b/views/default/settings/system.php index 8df843276..e335b8576 100644 --- a/views/default/settings/system.php +++ b/views/default/settings/system.php @@ -38,7 +38,10 @@ $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:allow_user_d $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:simplecache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:simplecache:label')), 'internalname' => 'simplecache_enabled', 'value' => ($vars['config']->simplecache_enabled ? elgg_echo('installation:simplecache:label') : "") )) . "</p>"; $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:viewpathcache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:viewpathcache:label')), 'internalname' => 'viewpath_cache_enabled', 'value' => (($vars['config']->viewpath_cache_enabled) ? elgg_echo('installation:viewpathcache:label') : "") )) . "</p>"; -$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>"; +$debug_options = array('0' => elgg_echo('installation:debug:none'), 'ERROR' => elgg_echo('installation:debug:error'), 'WARNING' => elgg_echo('installation:debug:warning'), 'NOTICE' => elgg_echo('installation:debug:notice')); +$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug'); +$form_body .= elgg_view('input/pulldown', array('options_values' => $debug_options, 'internalname' => 'debug', 'value' => $vars['config']->debug)); +$form_body .= '</p>'; $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>"; diff --git a/views/failsafe/settings/system.php b/views/failsafe/settings/system.php index aa06dd44c..dfc7ecc41 100644 --- a/views/failsafe/settings/system.php +++ b/views/failsafe/settings/system.php @@ -39,7 +39,10 @@ $form_body .= "<p>" . elgg_echo('installation:language') . elgg_view("input/pull $form_body .= "<p>" . elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => ACCESS_LOGGED_IN)) . "</p>"; -$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>"; +$debug_options = array('0' => elgg_echo('installation:debug:none'), 'ERROR' => elgg_echo('installation:debug:error'), 'WARNING' => elgg_echo('installation:debug:warning'), 'NOTICE' => elgg_echo('installation:debug:notice')); +$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug'); +$form_body .= elgg_view('input/pulldown', array('options_values' => $debug_options, 'internalname' => 'debug', 'value' => $vars['config']->debug)); +$form_body .= '</p>'; $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>"; |