From c92d1f32198d1364bae0fa28630810ff8e325ac0 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Fri, 12 Aug 2022 18:56:22 +1000 Subject: [PATCH] tweak(logger): mysql_debug array-check If the convar output is an array, check if the query was invoked by a resource in mysql_debug. --- src/logger/index.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/logger/index.ts b/src/logger/index.ts index 38c3519..a5b8eee 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -13,7 +13,14 @@ type QueryLog = Record; const logStorage: QueryLog = {}; export const logQuery = (invokingResource: string, query: string, executionTime: number, parameters: CFXParameters) => { - if (executionTime >= mysql_slow_query_warning || mysql_debug) + if (mysql_debug && Array.isArray(mysql_debug)) { + if (mysql_debug.includes(invokingResource)) { + console.log( + `^3[DEBUG] ${invokingResource} took ${executionTime}ms to execute a query! + ${query} ${JSON.stringify(parameters)}^0` + ); + } + } else if (mysql_debug || executionTime >= mysql_slow_query_warning) console.log( `^3[${mysql_debug ? 'DEBUG' : 'WARNING'}] ${invokingResource} took ${executionTime}ms to execute a query! ${query} ${JSON.stringify(parameters)}^0` @@ -35,8 +42,9 @@ RegisterCommand( (source: number) => { if (!mysql_ui) return; - if (source < 1) { // source is 0 when received from the server - console.log("^3This command cannot run server side^0"); + if (source < 1) { + // source is 0 when received from the server + console.log('^3This command cannot run server side^0'); return; }