feat(config): add command to modify mysql_debug

Allow toggling debug prints for specific resources during runtime.
This commit is contained in:
Linden committed 2022-08-12 19:47:30 +10:00
1 parent c92d1f3219
commit 7796c80f69
1 file changed
+26
+26
View File
@@ -26,3 +26,29 @@ export const mysql_transaction_isolation_level = (() => {
return `${query} READ COMMITTED`;
}
})();
RegisterCommand(
'oxmysql_debug',
(source: number, args: string[]) => {
if (source !== 0) return console.log('^3This command can only be run server side^0');
switch (args[0]) {
case 'add':
if (!Array.isArray(mysql_debug)) mysql_debug = [];
mysql_debug.push(args[1]);
return console.log(`^3Added ${args[1]} to mysql_debug^0`);
case 'remove':
if (Array.isArray(mysql_debug)) {
const index = mysql_debug.indexOf(args[1]);
if (index === -1) return;
mysql_debug.splice(index, 1);
if (mysql_debug.length === 0) mysql_debug = false;
return console.log(`^3Removed ${args[1]} from mysql_debug^0`);
}
default:
return console.log(`^3Usage: oxmysql add|remove <resource>^0`);
}
},
true
);