mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-04 14:38:50 +00:00
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:
1 parent
fca0b66fc8
commit
c92d1f3219
1 file changed
+11
-3
+11
-3
@@ -13,7 +13,14 @@ type QueryLog = Record<string, QueryData[]>;
|
|||||||
const logStorage: QueryLog = {};
|
const logStorage: QueryLog = {};
|
||||||
|
|
||||||
export const logQuery = (invokingResource: string, query: string, executionTime: number, parameters: CFXParameters) => {
|
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(
|
console.log(
|
||||||
`^3[${mysql_debug ? 'DEBUG' : 'WARNING'}] ${invokingResource} took ${executionTime}ms to execute a query!
|
`^3[${mysql_debug ? 'DEBUG' : 'WARNING'}] ${invokingResource} took ${executionTime}ms to execute a query!
|
||||||
${query} ${JSON.stringify(parameters)}^0`
|
${query} ${JSON.stringify(parameters)}^0`
|
||||||
@@ -35,8 +42,9 @@ RegisterCommand(
|
|||||||
(source: number) => {
|
(source: number) => {
|
||||||
if (!mysql_ui) return;
|
if (!mysql_ui) return;
|
||||||
|
|
||||||
if (source < 1) { // source is 0 when received from the server
|
if (source < 1) {
|
||||||
console.log("^3This command cannot run server side^0");
|
// source is 0 when received from the server
|
||||||
|
console.log('^3This command cannot run server side^0');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user