/** * Minimal structured warn-logger for scrapers. Matches the backend's * `${ISO} [WARN] [tag] msg key=value...` shape so warns from these files * grep alongside backend/src/log.ts output. Lives here (not in backend/) * because lib/scrapers/ is imported by both backend and Next.js code — * importing backend's log would cross a layering boundary. */ type Meta = Record; export function scraperWarn(tag: string, msg: string, meta?: Meta): void { const parts: string[] = []; if (meta) { for (const [k, v] of Object.entries(meta)) { if (v === undefined) continue; const s = typeof v === "string" ? v : JSON.stringify(v); parts.push(`${k}=${s}`); } } const tail = parts.length ? " " + parts.join(" ") : ""; console.warn(`${new Date().toISOString()} [WARN] [${tag}] ${msg}${tail}`); }