prisma-query-log
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -21,2 +21,10 @@ declare type PrismaQueryEvent = { | ||
unescape?: boolean; | ||
/** | ||
* Color of query (ANSI escape code) | ||
*/ | ||
colorQuery?: string; | ||
/** | ||
* Color of parameters (ANSI escape code) | ||
*/ | ||
colorParameter?: string; | ||
}; | ||
@@ -23,0 +31,0 @@ declare function createPrismaQueryEventHandler(args?: CreatePrismaQueryEventHandlerArgs): (event: PrismaQueryEvent) => void; |
15
index.js
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts | ||
function createPrismaQueryEventHandler(args = {}) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
const logger = args.logger === true ? console.log : (_a = args.logger) != null ? _a : false; | ||
@@ -9,2 +9,4 @@ if (!logger) { | ||
const unescape = (_b = args.unescape) != null ? _b : true; | ||
const colorParameter = (_c = args.colorParameter) != null ? _c : args.colorQuery; | ||
const colorQuery = args.colorQuery; | ||
return function prismaQueryLog(event) { | ||
@@ -17,5 +19,12 @@ const params = JSON.parse(event.params); | ||
query = query.replace(/\?/g, () => { | ||
return `${JSON.stringify(params.shift())}`; | ||
let parameter = JSON.stringify(params.shift()); | ||
if (colorQuery && colorParameter) { | ||
parameter = colorParameter + parameter + "[0m" + colorQuery; | ||
} | ||
return parameter; | ||
}); | ||
logger(`${query}`); | ||
if (colorQuery && colorParameter) { | ||
query = colorQuery + query + "[0m"; | ||
} | ||
logger(query); | ||
}; | ||
@@ -22,0 +31,0 @@ } |
{ | ||
"name": "prisma-query-log", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Log prisma query event", |
@@ -61,5 +61,14 @@ # prisma-query-log | ||
* Remove backticks. | ||
* Default: true | ||
*/ | ||
unescape?: boolean; | ||
/** | ||
* Color of query (ANSI escape code) | ||
*/ | ||
colorQuery?: string; | ||
/** | ||
* Color of parameters (ANSI escape code) | ||
*/ | ||
colorParameter?: string; | ||
}; | ||
``` |
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
7838
79
74