UNPKG

prisma-zod-generator

Version:

Prisma 2+ generator to emit Zod schemas from your Prisma schema

39 lines 1.51 kB
"use strict"; var _a, _b; Object.defineProperty(exports, "__esModule", { value: true }); exports.logger = void 0; /** * Simple logger that hides debug logs unless explicitly enabled. * * Enable with one of: * - DEBUG_PRISMA_ZOD=1|true * - DEBUG=1|true * - DEBUG including the substring "prisma-zod" (e.g. DEBUG=prisma-zod) */ const rawDebug = ((_b = (_a = process.env.DEBUG_PRISMA_ZOD) !== null && _a !== void 0 ? _a : process.env.DEBUG) !== null && _b !== void 0 ? _b : '').toLowerCase(); function parseEnabled(val) { if (!val) return false; if (val === '1' || val === 'true') return true; // Support namespaces like DEBUG=prisma-zod,prisma:* etc. return /(^|[,\s:*])(prisma[-_]?zod)([,\s:*]|$)/.test(val); } const enabled = parseEnabled(rawDebug); exports.logger = { debug: (...args) => { if (enabled) console.log(...args); }, info: (...args) => console.info(...args), // Warnings go to stdout, not stderr: Prisma runs generators as child // processes over JSON-RPC and does not surface their stderr, so a // console.warn is invisible to the person running `prisma generate` — // which would silently defeat every diagnostic we emit (skipped @zod // annotations, unknown config keys, unsupported Prisma versions, ...). warn: (...args) => console.log(...args), error: (...args) => console.error(...args), isDebugEnabled: () => enabled, }; exports.default = exports.logger; //# sourceMappingURL=logger.js.map