refactor: universal logger and remove N+1 catalog queries
- Replace all 39 console.* calls with universal logger (pino server, console browser) - Set server-only marker on import-badge.ts - Disable DB query logging in production - Add bulkInsertCatalogItems: one transaction instead of N per-item inserts - Add reserveCatalogItemIds helper for bulk ID allocation - Optimize translateCatalogItems: single inArray batch query instead of N per-item selects - Test mock updated for logger.debug - biome clean, tsc clean, 3569 tests passing
This commit is contained in:
1 parent
6895eaab49
commit
59a45d2165
27 files changed
+416
-241
No files matched your search
@@ -4,6 +4,7 @@ import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRef, useState, useTransition } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { logger } from "@/lib/logger";
|
||||
import type { ActionResult } from "@/lib/safe-action-shared";
|
||||
|
||||
interface UseServerActionOptions {
|
||||
@@ -97,7 +98,9 @@ export function useServerAction(options: UseServerActionOptions = {}) {
|
||||
onError?.();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[useServerAction] Unexpected error:", err);
|
||||
logger.error("[useServerAction] Unexpected error", {
|
||||
err: err as Error,
|
||||
});
|
||||
toast.error(errorMessage);
|
||||
onError?.();
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user