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.
This commit is contained in:
Linden committed 2022-08-12 18:56:22 +10:00
1 parent fca0b66fc8
commit c92d1f3219
1 file changed
+11 -3
+11 -3
View File
@@ -13,7 +13,14 @@ type QueryLog = Record<string, QueryData[]>;
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;
}