Skip to content

Commit

Permalink
fix(debug): load missing debug information on !_debug (#2624)
Browse files Browse the repository at this point in the history
Fixes #2901
  • Loading branch information
sogehige committed Sep 24, 2019
1 parent 0340a9c commit a24d308
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/bot/general.ts
Expand Up @@ -59,21 +59,23 @@ class General extends Core {
const enabledSystems: any = {};
for (const category of ['systems', 'games', 'integrations']) {
if (isNil(enabledSystems[category])) {
enabledSystems[category] = [];
enabledSystems[category] = [];
}
for (const system of Object.keys(global[category]).filter((o) => !o.startsWith('_'))) {
if (!global[category][system].settings) {
continue;
}
const [enabled, areDependenciesEnabled, isDisabledByEnv] = await Promise.all([
global[category][system].enabled,
global[category][system]._dependenciesEnabled(),
!isNil(process.env.DISABLE) && (process.env.DISABLE.toLowerCase().split(',').includes(system.toLowerCase()) || process.env.DISABLE === '*'),
]);
if (!enabled || !areDependenciesEnabled || isDisabledByEnv) {
continue;
if (!enabled) {
enabledSystems[category].push('-' + system);
} else if (!areDependenciesEnabled) {
enabledSystems[category].push('-dep-' + system);
} else if (isDisabledByEnv) {
enabledSystems[category].push('-env-' + system);
} else {
enabledSystems[category].push(system);
}
enabledSystems[category].push(system);
}
}
const version = get(process, 'env.npm_package_version', 'x.y.z');
Expand All @@ -83,7 +85,7 @@ class General extends Core {
global.log.debug(` | DB: ${config.database.type}`);
global.log.debug(` | Threads: ${global.cpu}`);
global.log.debug(` | HEAP: ${Number(process.memoryUsage().heapUsed / 1048576).toFixed(2)} MB`);
global.log.debug(` | Uptime: ${process.uptime()} seconds`);
global.log.debug(` | Uptime: ${Math.trunc(process.uptime())} seconds`);
global.log.debug(` | Language: ${lang}`);
global.log.debug(` | Mute: ${mute}`);
global.log.debug(`SYSTEMS | ${enabledSystems.systems.join(', ')}`);
Expand Down Expand Up @@ -134,7 +136,7 @@ class General extends Core {

private async setStatus(opts: CommandOptions & { enable: boolean }) {
if (opts.parameters.trim().length === 0) {
return;
return;
}
try {
const [type, name] = opts.parameters.split(' ');
Expand Down
5 changes: 4 additions & 1 deletion src/bot/logging.js
Expand Up @@ -64,7 +64,10 @@ if (!isMainThread) {
format.printf(info => {
let level
if (info.level === 'error') level = '!!! ERROR !!!'
if (info.level === 'debug') level = chalk.bgRed.bold('DEBUG:')
if (info.level === 'debug') {
level = chalk.bgRed.bold('DEBUG:');
info.category = '';
}
if (info.level === 'chatIn') level = '<<<'
if (info.level === 'chatOut') level = '>>>'
if (info.level === 'whisperIn') level = '<w<'
Expand Down

0 comments on commit a24d308

Please sign in to comment.