mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 14:38:50 +00:00
refactor(logger): only enable profiling with debugging
Breaks slow query warnings, but most people just set the number higher once they get warnings anyway. Also fixes some issues: - profile duration formatting and time (sec to ms). - incorrect log query/param index.
This commit is contained in:
1 parent
bdbe86c0f7
commit
45aadf7442
5 files changed
+43
-19
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { pool } from '.';
|
||||
import { profileBatchStatements } from '../logger';
|
||||
import { profileBatchStatements, runProfiler } from '../logger';
|
||||
import { CFXCallback, CFXParameters } from '../types';
|
||||
import { parseResponse } from '../utils/parseResponse';
|
||||
import { executeType, parseExecute } from '../utils/parseExecute';
|
||||
@@ -36,6 +36,7 @@ export const rawExecute = (
|
||||
if (!connection) return;
|
||||
|
||||
const parametersLength = parameters.length == 0 ? 1 : parameters.length;
|
||||
const hasProfiler = await runProfiler(connection, invokingResource);
|
||||
|
||||
for (let index = 0; index < parametersLength; index++) {
|
||||
const values = parameters[index];
|
||||
@@ -57,8 +58,8 @@ export const rawExecute = (
|
||||
} else response.push(parseResponse(type, result));
|
||||
}
|
||||
|
||||
if ((index > 0 && index % 99 === 0) || index === parametersLength - 1) {
|
||||
await profileBatchStatements(connection, invokingResource, query, parameters, index);
|
||||
if (hasProfiler && ((index > 0 && index % 100 === 0) || index === parametersLength - 1)) {
|
||||
await profileBatchStatements(connection, invokingResource, query, parameters, index < 100 ? 0 : index);
|
||||
}
|
||||
|
||||
if (index === parametersLength - 1) {
|
||||
|
||||
Reference in new issue
Block a user