prisma-query-log
Advanced tools
Comparing version 2.0.1 to 2.0.2
29
index.js
@@ -27,8 +27,9 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __assign = Object.assign; | ||
} | ||
const {unescape, colorQuery, format} = options; | ||
const {unescape, format} = options; | ||
const formatterOptions = __assign(__assign({}, options.formatterOptions), customFormatterOptions); | ||
const colorQuery = format ? false : options.colorQuery; | ||
const colorParameter = (_c = options.colorParameter) != null ? _c : colorQuery; | ||
return function prismaQueryLog(event) { | ||
const eventParams = event.params.replace(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ UTC/g, (date) => `"${date}"`); | ||
let params = JSON.parse(eventParams); | ||
const params = JSON.parse(eventParams); | ||
let query = event.query; | ||
@@ -38,2 +39,9 @@ if (unescape) { | ||
} | ||
query = query.replace(/\?/g, () => { | ||
let parameter = JSON.stringify(params.shift()); | ||
if (colorQuery && colorParameter) { | ||
parameter = colorParameter + parameter + "[0m" + colorQuery; | ||
} | ||
return parameter; | ||
}); | ||
if (format) { | ||
@@ -43,16 +51,7 @@ if (!formatter) { | ||
} | ||
params = params.map((p) => JSON.stringify(p)); | ||
query = "\n" + formatter.format(query, __assign(__assign({}, formatterOptions), {params})).trim(); | ||
} else { | ||
query = query.replace(/\?/g, () => { | ||
let parameter = JSON.stringify(params.shift()); | ||
if (colorQuery && colorParameter) { | ||
parameter = colorParameter + parameter + "[0m" + colorQuery; | ||
} | ||
return parameter; | ||
}); | ||
if (colorQuery && colorParameter) { | ||
query = colorQuery + query + "[0m"; | ||
} | ||
query = "\n" + formatter.format(query, formatterOptions).trim(); | ||
} | ||
if (colorQuery && colorParameter) { | ||
query = colorQuery + query + "[0m"; | ||
} | ||
logger(query); | ||
@@ -59,0 +58,0 @@ }; |
{ | ||
"name": "prisma-query-log", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Log prisma query event", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9608
122