MCPcopy
hub / github.com/sequelize/sequelize / _logQuery

Method _logQuery

lib/dialects/abstract/query.js:331–361  ·  view source on GitHub ↗

* @param {string} sql * @param {Function} debugContext * @param {Array|object} parameters * @protected * @returns {Function} A function to call after the query was completed.

(sql, debugContext, parameters)

Source from the content-addressed store, hash-verified

329 * @returns {Function} A function to call after the query was completed.
330 */
331 _logQuery(sql, debugContext, parameters) {
332 const { connection, options } = this;
333 const benchmark = this.sequelize.options.benchmark || options.benchmark;
334 const logQueryParameters = this.sequelize.options.logQueryParameters || options.logQueryParameters;
335 const startTime = Date.now();
336 let logParameter = '';
337
338 if (logQueryParameters && parameters) {
339 const delimiter = sql.endsWith(';') ? '' : ';';
340 let paramStr;
341 if (Array.isArray(parameters)) {
342 paramStr = parameters.map(p=>JSON.stringify(p)).join(', ');
343 } else {
344 paramStr = JSON.stringify(parameters);
345 }
346 logParameter = `${delimiter} ${paramStr}`;
347 }
348 const fmt = `(${connection.uuid || 'default'}): ${sql}${logParameter}`;
349 const msg = `Executing ${fmt}`;
350 debugContext(msg);
351 if (!benchmark) {
352 this.sequelize.log(`Executing ${fmt}`, options);
353 }
354 return () => {
355 const afterMsg = `Executed ${fmt}`;
356 debugContext(afterMsg);
357 if (benchmark) {
358 this.sequelize.log(afterMsg, Date.now() - startTime, options);
359 }
360 };
361 }
362
363 /**
364 * The function takes the result of the query execution and groups

Callers 7

runMethod · 0.80
runMethod · 0.80
_runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
query.test.jsFile · 0.80

Calls 2

logMethod · 0.80
stringifyMethod · 0.65

Tested by

no test coverage detected