Commit 06e17c81 authored by profix898's avatar profix898

- feature: improved debug output

parent fb145d28
......@@ -77,7 +77,7 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
}
// Prepare array with init parameters
$debug = variable_get('gallery_debug', 0) && user_access('administer site configuration');
$debug = variable_get('gallery_g2debug', 0) && user_access('administer site configuration');
$params = array('g2Dir' => $g2_dir,
'g2Uri' => $g2_uri,
'embedUri' => $embed_uri,
......@@ -547,7 +547,7 @@ function gallery_context(&$params, $setcontext = FALSE) {
if ($setcontext) {
// store new context
$context_cache = (isset($params) && count($params)) ? $params : array();
gallery_debug(array_keys($context_cache), t('Context cache'));
gallery_debug($context_cache, t('Context cache'));
}
else if (isset($context_cache)) {
// get context parameters
......@@ -708,10 +708,16 @@ function _gallery_report_error($report = array()) {
/**
* Function gallery_debug().
*/
function gallery_debug($array, $label = 'Gallery Debug') {
function gallery_debug($array, $label = '') {
if (variable_get('gallery_debug', 0) && user_access('administer site configuration')) {
// TODO: output to footer in a collapsible fieldset
drupal_set_message('<strong>'. $label .':</strong><br />'. nl2br(htmlspecialchars(print_r($array, TRUE))), 'error');
// Output debug log into a collapsible fieldset
$fieldset = array(
'#title' => check_plain('Gallery Debug: '. $label),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#value' => '<pre>'. print_r($array, TRUE) .'</pre>',
);
drupal_set_content('content', theme('fieldset', $fieldset));
}
}
......
......@@ -172,13 +172,26 @@ function _gallery_settings_general() {
user is redirected to the search form.'),
'#disabled' => !$search_status,
);
$form['error']['gallery_debug'] = array(
$form['error']['debug'] = array(
'#type' => 'fieldset',
'#title' => t('Debug settings'),
'#description' => '',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['error']['debug']['gallery_debug'] = array(
'#type' => 'checkbox',
'#title' => t('Enable debug mode'),
'#default_value' => variable_get('gallery_debug', 0),
'#description' => t('Print out debug variables and verbose error messages. Only visible to users
with \'administer site configuration\' permission.')
);
$form['error']['debug']['gallery_g2debug'] = array(
'#type' => 'checkbox',
'#title' => t('Enable G2 debug output'),
'#default_value' => variable_get('gallery_g2debug', 0),
'#description' => t('Enables Gallery2\'s buffered debug output to be displayed.')
);
// Relevant links
$form['links'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment