MCPcopy Index your code
hub / github.com/sequelize/sequelize / _logQuery

Method _logQuery

src/dialects/abstract/query.js:355–385  ·  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

353 * @returns {Function} A function to call after the query was completed.
354 */
355 _logQuery(sql, debugContext, parameters) {
356 const { connection, options } = this;
357 const benchmark = this.sequelize.options.benchmark || options.benchmark;
358 const logQueryParameters = this.sequelize.options.logQueryParameters || options.logQueryParameters;
359 const startTime = Date.now();
360 let logParameter = '';
361
362 if (logQueryParameters && parameters) {
363 const delimiter = sql.endsWith(';') ? '' : ';';
364 let paramStr;
365 if (Array.isArray(parameters)) {
366 paramStr = parameters.map(p=>safeStringifyJson(p)).join(', ');
367 } else {
368 paramStr = safeStringifyJson(parameters);
369 }
370 logParameter = `${delimiter} ${paramStr}`;
371 }
372 const fmt = `(${connection.uuid || 'default'}): ${sql}${logParameter}`;
373 const msg = `Executing ${fmt}`;
374 debugContext(msg);
375 if (!benchmark) {
376 this.sequelize.log(`Executing ${fmt}`, options);
377 }
378 return () => {
379 const afterMsg = `Executed ${fmt}`;
380 debugContext(afterMsg);
381 if (benchmark) {
382 this.sequelize.log(afterMsg, Date.now() - startTime, options);
383 }
384 };
385 }
386
387 /**
388 * The function takes the result of the query execution and groups

Callers 8

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

Calls 2

safeStringifyJsonFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected