]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Adding debug options to admin site settings.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 19 Oct 2009 17:15:35 +0000 (17:15 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 19 Oct 2009 17:15:35 +0000 (17:15 +0000)
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

CHANGES.txt
actions/admin/site/update_basic.php
actions/systemsettings/install.php
engine/lib/elgglib.php
languages/en.php
views/default/settings/system.php
views/failsafe/settings/system.php

index e106b5139f58d30a3af56251a5e093e518e6e42e..16f5cb4bd81b2dd36a817f0a3f90f1c2334f74f0 100644 (file)
@@ -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
index 0b567340c2967e1498744ea00b8a204d0b726f82..70cc7273027a53a4470308251946795cdf2b45cf 100644 (file)
@@ -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());
                }
index 819ef08eebed0907afee9b85f9c2df5f7868597a..ef606315b7355e7e251cd50b68b96eccc58eb6c1 100644 (file)
@@ -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());
                }
index 36e87eca9d65c05b093ebf65d9078cd6c89c5c3a..a77922a9f184f427c00bfc7fcb33d4e205fa11b0 100644 (file)
@@ -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);
+       }
 }
 
 /**
index c93f36fd7b6592458541f46e0bbb14309eab2d94..310f5cd091a05673d0f8498b65153754a8f63a18 100644 (file)
@@ -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.",
index 8df843276b823ae020d11682376ef4ae4704c242..e335b85760ee2e0ac81a11d9a57b5c96234a6b2b 100644 (file)
@@ -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>";
 
index aa06dd44c68d3efea69bde2397eda5aa4ac03002..dfc7ecc41e2f6f270f196b5d9512adda0cdd8250 100644 (file)
@@ -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>";