Add performance logging
This commit is contained in:
parent
e841f20ab0
commit
e5032d8cd4
4 changed files with 24 additions and 5 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -2187,9 +2187,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"knub": {
|
"knub": {
|
||||||
"version": "16.3.0",
|
"version": "16.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/knub/-/knub-16.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/knub/-/knub-16.4.0.tgz",
|
||||||
"integrity": "sha512-sT0sntmffQjhQaA3OjmjDBuplgnPtbmaFSGpYsi8icYtqFOmlDwXHpOOVRxBGomWH7SbHf3TP7EFQRh/WXAvNg==",
|
"integrity": "sha512-kPWa306o4inVazFacyD5kiv4j1RR2iKuIkrGdqSlhoCAq4tYplqiXxnabl15EDAlHZzXKj9f7aSF8f9mCio/vA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
"lodash.at": "^4.6.0",
|
"lodash.at": "^4.6.0",
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
"humanize-duration": "^3.15.0",
|
"humanize-duration": "^3.15.0",
|
||||||
"js-yaml": "^3.12.0",
|
"js-yaml": "^3.12.0",
|
||||||
"knub": "^16.3.0",
|
"knub": "^16.4.0",
|
||||||
"lodash.at": "^4.6.0",
|
"lodash.at": "^4.6.0",
|
||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
"lodash.difference": "^4.5.0",
|
"lodash.difference": "^4.5.0",
|
||||||
|
|
|
@ -144,6 +144,12 @@ connect().then(async conn => {
|
||||||
if (level === "debug") return;
|
if (level === "debug") return;
|
||||||
const ts = moment().format("YYYY-MM-DD HH:mm:ss");
|
const ts = moment().format("YYYY-MM-DD HH:mm:ss");
|
||||||
console.log(`[${ts}] [${level.toUpperCase()}] ${msg}`);
|
console.log(`[${ts}] [${level.toUpperCase()}] ${msg}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
performanceDebug: {
|
||||||
|
enabled: true,
|
||||||
|
size: 30,
|
||||||
|
threshold: 200
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ let activeReload: [string, string] = null;
|
||||||
* A global plugin that allows bot owners to control the bot
|
* A global plugin that allows bot owners to control the bot
|
||||||
*/
|
*/
|
||||||
export class BotControlPlugin extends GlobalPlugin {
|
export class BotControlPlugin extends GlobalPlugin {
|
||||||
public static pluginName = 'bot_control';
|
public static pluginName = "bot_control";
|
||||||
|
|
||||||
getDefaultOptions() {
|
getDefaultOptions() {
|
||||||
return {
|
return {
|
||||||
|
@ -68,4 +68,17 @@ export class BotControlPlugin extends GlobalPlugin {
|
||||||
|
|
||||||
this.knub.reloadAllGlobalPlugins();
|
this.knub.reloadAllGlobalPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@d.command("perf")
|
||||||
|
async perfCmd(msg: Message) {
|
||||||
|
if (!this.isOwner(msg.author.id)) return;
|
||||||
|
const perfItems = this.knub.getPerformanceDebugItems();
|
||||||
|
|
||||||
|
if (perfItems.length) {
|
||||||
|
const content = "```" + perfItems.join("\n") + "```";
|
||||||
|
msg.channel.createMessage(content);
|
||||||
|
} else {
|
||||||
|
msg.channel.createMessage(errorMessage("No performance data"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue