Update query log on requests
This commit is contained in:
parent
8084a84576
commit
58012f5808
|
@ -53,6 +53,8 @@ $content = $l['handler'](...$l['params'] ?? []);
|
||||||
if (is_htmx()) {
|
if (is_htmx()) {
|
||||||
$content .= '<title>'.page_title().'</title>';
|
$content .= '<title>'.page_title().'</title>';
|
||||||
$content .= Render\debug_db_info();
|
$content .= Render\debug_db_info();
|
||||||
|
if (env('debug', false)) $content .= Render\debug_query_log();
|
||||||
|
|
||||||
if ($GLOBALS['state']['user-state-changed'] ?? false) {
|
if ($GLOBALS['state']['user-state-changed'] ?? false) {
|
||||||
$content .= Render\right_nav();
|
$content .= Render\right_nav();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,3 +43,14 @@ function babblebox(): string
|
||||||
{
|
{
|
||||||
return render('babblebox', ['messages' => babblebox_messages()]);
|
return render('babblebox', ['messages' => babblebox_messages()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function debug_query_log(): string
|
||||||
|
{
|
||||||
|
$html = '<pre id="debug-query-log" hx-swap-oob="true">';
|
||||||
|
foreach (db()->log as $record) {
|
||||||
|
$query_string = str_replace(["\r\n", "\n", "\r"], ' ', $record[0]);
|
||||||
|
$error_string = !empty($record[2]) ? '// '.$record[2] : '';
|
||||||
|
$html .= '<div>['.round($record[1], 2)."s] {$query_string}{$error_string}</div>";
|
||||||
|
}
|
||||||
|
return $html . '</pre>';
|
||||||
|
}
|
||||||
|
|
|
@ -40,27 +40,7 @@
|
||||||
<div>Version <?= VERSION ?> <?= BUILD ?></div>
|
<div>Version <?= VERSION ?> <?= BUILD ?></div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<?php
|
<?php if (env('debug', false)) echo Render\debug_query_log(); ?>
|
||||||
if (env('debug', false)) {
|
|
||||||
echo '<pre>';
|
|
||||||
foreach (db()->log as $record) {
|
|
||||||
$query_string = str_replace(["\r\n", "\n", "\r"], ' ', $record[0]);
|
|
||||||
$error_string = !empty($record[2]) ? '// '.$record[2] : '';
|
|
||||||
echo '<div>['.round($record[1], 2)."s] {$query_string}{$error_string}</div>";
|
|
||||||
}
|
|
||||||
echo '</pre>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
document.addEventListener("updateTitle", (event) => {
|
|
||||||
const title = event.detail?.title
|
|
||||||
if (title) {
|
|
||||||
console.log('New title:', title);
|
|
||||||
document.title = title;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user