Option to log db queries in dev mode

This commit is contained in:
Philipinho 2025-03-03 14:19:44 +00:00
parent 72f64e7b10
commit 453617f293

View File

@ -45,12 +45,15 @@ types.setTypeParser(types.builtins.INT8, (val) => Number(val));
plugins: [new CamelCasePlugin()],
log: (event: LogEvent) => {
if (environmentService.getNodeEnv() !== 'development') return;
const logger = new Logger(DatabaseModule.name);
if (event.level === 'query') {
// console.log(event.query.sql);
if (process.env.DEBUG_DB?.toLowerCase() === 'true') {
logger.debug(event.query.sql);
logger.debug('query time: ' + event.queryDurationMillis + ' ms');
//if (event.query.parameters.length > 0) {
//console.log('parameters: ' + event.query.parameters);
// logger.debug('parameters: ' + event.query.parameters);
//}
// console.log('time: ' + event.queryDurationMillis);
}
}
},
}),