전체 코드, 구조 검토 - P0 코드 수정 진행

This commit is contained in:
2026-07-04 10:13:12 +09:00
parent 854a3e2bfb
commit 3c5848cdc5
9 changed files with 339 additions and 101 deletions
+8 -2
View File
@@ -58,6 +58,12 @@ function onQuery(e: Prisma.QueryEvent): void {
const COL_MAX_WIDTH = 40;
const SENSITIVE_KEYS = new Set(["Password", "password"]);
function safeValue(key: string, value: unknown): string {
return SENSITIVE_KEYS.has(key) ? "***" : formatValue(value);
}
function formatValue(v: unknown): string {
if (v === null || v === undefined) return "NULL";
if (typeof v === "bigint") return v.toString();
@@ -165,7 +171,7 @@ function buildResultLog(
if (typeof preview[0] === "object" && preview[0] !== null) {
const objRows = preview as Record<string, unknown>[];
const headers = Object.keys(objRows[0]);
const rows = objRows.map((row) => headers.map((h) => formatValue(row[h])));
const rows = objRows.map((row) => headers.map((h) => safeValue(h, row[h])));
return `${label}${countLabel}\n${renderTable(headers, rows)}${moreLabel}`;
}
@@ -176,7 +182,7 @@ function buildResultLog(
if (result !== null && typeof result === "object") {
const rows = Object.entries(result as Record<string, unknown>).map(([k, v]) => [
k,
formatValue(v),
safeValue(k, v),
]);
return `${label}\n${renderTable(["field", "value"], rows)}`;
}