웹 로그, DB 쿼리문과 결과 로그 출력

This commit is contained in:
2026-06-22 22:34:56 +09:00
parent bcd0ef2af3
commit f384388c67
21 changed files with 706 additions and 214 deletions
+15
View File
@@ -1,6 +1,7 @@
import { z } from "zod";
import { db } from "@/lib/db";
import { logger } from "@/lib/logger";
import type { Prisma } from "@/lib/generated/prisma/client";
const pageSizeOptions = [10, 20, 50, 100] as const;
@@ -104,6 +105,7 @@ export type MaestroDetail = {
export async function getMaestros(
rawSearchParams: RawSearchParams = {}
): Promise<MaestroListResult> {
const t0 = Date.now();
const params = parseMaestroListSearchParams(rawSearchParams);
const where = buildMaestroWhere(params);
const orderBy = buildMaestroOrderBy(params.sort);
@@ -131,6 +133,12 @@ export async function getMaestros(
const totalPages = Math.max(1, Math.ceil(totalCount / params.pageSize));
logger.info("maestros", "list fetched", {
totalCount,
page: params.page,
duration: Date.now() - t0,
});
return {
items: maestros.map(toMaestroListItem),
page: params.page,
@@ -147,6 +155,7 @@ export async function getMaestros(
export async function getMaestroDetail(
maestroID: number
): Promise<MaestroDetail | null> {
const t0 = Date.now();
const maestro = await db.maestro.findUnique({
where: { MaestroID: maestroID },
select: {
@@ -164,6 +173,7 @@ export async function getMaestroDetail(
});
if (!maestro) {
logger.warn("maestros/[id]", "not found", { id: maestroID });
return null;
}
@@ -229,6 +239,11 @@ export async function getMaestroDetail(
}),
]);
logger.info("maestros/[id]", "fetched", {
id: maestroID,
duration: Date.now() - t0,
});
return {
maestro: {
...toMaestroListItem(maestro),