mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-12 05:22:35 +09:00
Allow multiple selection of display debug types
This commit is contained in:
parent
0dd20267af
commit
b048200a30
5 changed files with 33 additions and 20 deletions
|
|
@ -157,16 +157,22 @@ class DisplayHandler extends Handler
|
|||
}
|
||||
|
||||
// Do not display debugging information if there is no output.
|
||||
$display_type = config('debug.display_type');
|
||||
if ($output === null && $display_type !== 'file')
|
||||
$display_types = config('debug.display_type');
|
||||
if (!is_array($display_types))
|
||||
{
|
||||
$display_types = array($display_types);
|
||||
}
|
||||
if ($output === null && !in_array('file', $display_types))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Print debug information.
|
||||
switch ($display_type)
|
||||
$debug_output = '';
|
||||
foreach ($display_types as $display_type)
|
||||
{
|
||||
case 'panel':
|
||||
if ($display_type === 'panel')
|
||||
{
|
||||
$data = Rhymix\Framework\Debug::getDebugData();
|
||||
$display_content = array_fill_keys(config('debug.display_content'), true);
|
||||
if (count($display_content) && !isset($display_content['entries']))
|
||||
|
|
@ -220,7 +226,7 @@ class DisplayHandler extends Handler
|
|||
$panel_script .= "\n<script>\nvar rhymix_debug_content = " . json_encode($data, $json_options) . ";\n</script>";
|
||||
$body_end_position = strrpos($output, '</body>') ?: strlen($output);
|
||||
$output = substr($output, 0, $body_end_position) . "\n$panel_script\n" . substr($output, $body_end_position);
|
||||
return;
|
||||
break;
|
||||
case 'JSON':
|
||||
if (RX_POST && preg_match('/^proc/', Context::get('act')))
|
||||
{
|
||||
|
|
@ -236,17 +242,16 @@ class DisplayHandler extends Handler
|
|||
{
|
||||
$output = $matches[1] . ',"_rx_debug":' . json_encode($data) . '}';
|
||||
}
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'comment':
|
||||
case 'file':
|
||||
default:
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($display_type === 'comment' && Context::getResponseMethod() !== 'HTML')
|
||||
{
|
||||
return;
|
||||
break;
|
||||
}
|
||||
ob_start();
|
||||
$data = Rhymix\Framework\Debug::getDebugData();
|
||||
|
|
@ -272,13 +277,16 @@ class DisplayHandler extends Handler
|
|||
$phpheader = '';
|
||||
}
|
||||
FileHandler::writeFile($log_filename, $phpheader . $content . PHP_EOL, 'a');
|
||||
return '';
|
||||
$debug_output .= '';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '<!--' . PHP_EOL . $content . PHP_EOL . '-->';
|
||||
$debug_output .= '<!--' . PHP_EOL . $content . PHP_EOL . '-->' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $debug_output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ return array(
|
|||
'log_slow_widgets' => 0,
|
||||
'log_slow_remote_requests' => 0,
|
||||
'log_filename' => null,
|
||||
'display_type' => 'comment',
|
||||
'display_type' => array('comment'),
|
||||
'display_content' => array(),
|
||||
'display_to' => 'admin',
|
||||
'write_error_log' => 'fatal',
|
||||
|
|
|
|||
|
|
@ -806,13 +806,18 @@ class adminAdminController extends admin
|
|||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Save display type settings
|
||||
$display_type = array_values(array_filter($vars->debug_display_type, function($str) {
|
||||
return in_array($str, ['panel', 'comment', 'file']);
|
||||
}));
|
||||
|
||||
// Debug settings
|
||||
Rhymix\Framework\Config::set('debug.enabled', $vars->debug_enabled === 'Y');
|
||||
Rhymix\Framework\Config::set('debug.log_slow_queries', max(0, floatval($vars->debug_log_slow_queries)));
|
||||
Rhymix\Framework\Config::set('debug.log_slow_triggers', max(0, floatval($vars->debug_log_slow_triggers)));
|
||||
Rhymix\Framework\Config::set('debug.log_slow_widgets', max(0, floatval($vars->debug_log_slow_widgets)));
|
||||
Rhymix\Framework\Config::set('debug.log_slow_remote_requests', max(0, floatval($vars->debug_log_slow_remote_requests)));
|
||||
Rhymix\Framework\Config::set('debug.display_type', strval($vars->debug_display_type) ?: 'comment');
|
||||
Rhymix\Framework\Config::set('debug.display_type', $display_type);
|
||||
Rhymix\Framework\Config::set('debug.display_to', strval($vars->debug_display_to) ?: 'admin');
|
||||
Rhymix\Framework\Config::set('debug.write_error_log', strval($vars->debug_write_error_log) ?: 'fatal');
|
||||
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ class adminAdminView extends admin
|
|||
Context::set('debug_log_slow_widgets', Rhymix\Framework\Config::get('debug.log_slow_widgets'));
|
||||
Context::set('debug_log_slow_remote_requests', Rhymix\Framework\Config::get('debug.log_slow_remote_requests'));
|
||||
Context::set('debug_log_filename', Rhymix\Framework\Config::get('debug.log_filename') ?: 'files/debug/YYYYMMDD.php');
|
||||
Context::set('debug_display_type', Rhymix\Framework\Config::get('debug.display_type'));
|
||||
Context::set('debug_display_type', (array)Rhymix\Framework\Config::get('debug.display_type'));
|
||||
Context::set('debug_display_content', Rhymix\Framework\Config::get('debug.display_content'));
|
||||
Context::set('debug_display_to', Rhymix\Framework\Config::get('debug.display_to'));
|
||||
Context::set('debug_write_error_log', Rhymix\Framework\Config::get('debug.write_error_log'));
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="debug_log_slow_widgets">{$lang->debug_display_type}</label>
|
||||
<div class="x_controls">
|
||||
<label for="debug_display_type_comment" class="x_inline"><input type="radio" name="debug_display_type" id="debug_display_type_comment" value="comment" checked="checked"|cond="$debug_display_type=='comment'" /> {$lang->debug_display_type_comment}</label>
|
||||
<label for="debug_display_type_panel" class="x_inline"><input type="radio" name="debug_display_type" id="debug_display_type_panel" value="panel" checked="checked"|cond="$debug_display_type=='panel'" /> {$lang->debug_display_type_panel}</label>
|
||||
<label for="debug_display_type_file" class="x_inline"><input type="radio" name="debug_display_type" id="debug_display_type_file" value="file" checked="checked"|cond="$debug_display_type=='file'" /> {$lang->debug_display_type_file}</label>
|
||||
<label for="debug_display_type_comment" class="x_inline"><input type="checkbox" name="debug_display_type[]" id="debug_display_type_comment" value="comment" checked="checked"|cond="in_array('comment', $debug_display_type)" /> {$lang->debug_display_type_comment}</label>
|
||||
<label for="debug_display_type_panel" class="x_inline"><input type="checkbox" name="debug_display_type[]" id="debug_display_type_panel" value="panel" checked="checked"|cond="in_array('panel', $debug_display_type)" /> {$lang->debug_display_type_panel}</label>
|
||||
<label for="debug_display_type_file" class="x_inline"><input type="checkbox" name="debug_display_type[]" id="debug_display_type_file" value="file" checked="checked"|cond="in_array('file', $debug_display_type)" /> {$lang->debug_display_type_file}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue