debugbar 쿼리 오류 표시 추가 및 G5_COLLECT_QUERY 설정 추가

- 210 이슈에서 제안했던 개선안
- debugbar에 오류 등으로 실패한 쿼리가 나오지 않는 문제 수정
- 실패한 쿼리에 오류 메시지 출력
- 쿼리가 실행된 파일, 라인 함수 표시
- G5_COLLECT_QUERY 상수 설정 추가로 디버그 모드(G5_DEBUG)를 켜지 않아도 서드파티 플러그인에서 쿼리 목록을 수집할 수 있도록 개선
This commit is contained in:
kkigomi
2022-11-27 01:46:26 +09:00
parent cd50af93fd
commit 6d9db83789
4 changed files with 82 additions and 9 deletions

View File

@ -54,7 +54,27 @@ add_stylesheet('<link rel="stylesheet" href="'.G5_PLUGIN_URL.'/debugbar/style.cs
?>
<tr>
<td scope="row" data-label="실행순서"><?php echo $key; ?></td>
<td class="left" data-label="쿼리문"><?php echo $query['sql']; ?></td>
<td class="left" data-label="쿼리문">
<?php
if(isset($query['source']['class'])) {
$function = "{$query['source']['class']}{$query['source']['type']}{$query['source']['function']}()";
} else if (isset($query['source']['function'])) {
$function = "{$query['source']['function']}()";
} else {
$function = null;
}
?>
<p class="query_source">
<em><?php echo "{$query['source']['file']}:{$query['source']['line']}" ?></em><br>
<?php if($function) { echo "<em>{$function}</em><br>"; } ?>
</p>
<?php
echo "<p class=\"query_sql\">{$query['sql']}</p>";
if(!$query['success']) {
echo '<p class="query_error_message">오류: [' . $query['error_code'] . '] ' . $query['error_message'] . '</p>';
}
?>
</td>
<td data-label="실행시간"><?php echo $show_excuted_time.' ms'; ?></td>
</tr>
<?php } ?>

View File

@ -23,12 +23,14 @@
.debug_table{border:1px solid #ccc;border-collapse:collapse;margin:0;padding:0;width:100%}
.debug_table caption{display:none}
.debug_table tr{background:#f8f8f8;border:1px solid #ddd;padding:.35em}
.debug_table th,.debug_table td{padding:.625em;text-align:center}
.debug_table th,.debug_table td{padding:.625em;text-align:center;white-space:nowrap;}
.debug_table tbody tr:hover td{background:#c7d4dd!important}
.debug_table tbody tr:nth-child(even){background-color:#fff}
.debug_table td.left{text-align:left}
.debug_table td.left{text-align:left;font-family:monospace;white-space:initial}
.debug_table th{font-size:.85em;letter-spacing:.1em;text-transform:uppercase}
.debug_table td img{text-align:center}
.debug_table .query_sql {font-weight:bold;margin:.5em 0}
.debug_table .query_error_message {color:red;margin:.5em 0}
.debug_table.hook_table th, .debug_table.hook_table td {text-align:left;border:1px solid #ddd;}
.hook_table .hook_count{margin-left:3px;font-size:0.9em;color:#7cbc0a}