diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bba3a9..8ca41d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - changed interface to fit the new graphql schema - changed module export definition to `Object.assign(exports, {...})` at the end of the module file - added section `commandSettings` to config.js file +- added module information to webinterface log ### Removed - removed lib/cmd because all functionalities are now adapted to the MessageHandler and CommadnHandlers diff --git a/bot.js b/bot.js index 0edd8db..c2fe03c 100644 --- a/bot.js +++ b/bot.js @@ -246,19 +246,19 @@ class Bot { // Executing the main function if (typeof require !== 'undefined' && require.main === module) { - let logger = logging.logger; - logger.info("Starting up... ", {m: 'bot.init'}); - logger.debug('Calling constructor...', {m: 'bot.init'}); + let logger = new logging.Logger('MAIN-init'); + logger.info("Starting up... "); + logger.debug('Calling constructor...'); let discordBot = new Bot(); - logger.debug('Initializing services...', {m: 'bot.init'}); + logger.debug('Initializing services...'); discordBot.initServices().then(() => { - logger.debug('Starting Bot...', {m: 'bot.init'}); + logger.debug('Starting Bot...'); discordBot.start().catch((err) => { //eslint-disable-line promise/no-nesting - logger.error(err.message, {m: 'bot.init'}); - logger.debug(err.stack, {m: 'bot.init'}); + logger.error(err.message); + logger.debug(err.stack); }); }).catch((err) => { - logger.error(err.message, {m: 'bot.init'}); - logger.debug(err.stack, {m: 'bot.init'}); + logger.error(err.message); + logger.debug(err.stack); }); } diff --git a/lib/CommandLib.js b/lib/CommandLib.js index 7cf44c3..527c794 100644 --- a/lib/CommandLib.js +++ b/lib/CommandLib.js @@ -247,7 +247,9 @@ class ExtendedRichEmbed extends Discord.RichEmbed { * @param value */ setDescription(value) { - let croppedValue = value.substring(0, 1024); + let croppedValue = value; + if (value.substring) + croppedValue = value.substring(0, 1024); if (croppedValue.length < value.length) croppedValue = croppedValue.replace(/\n.*$/g, ''); super.setDescription(croppedValue); @@ -259,9 +261,11 @@ class ExtendedRichEmbed extends Discord.RichEmbed { * @param value */ addField(name, value) { - let croppedValue = value.substring(0, 1024); - if (croppedValue.length < value.length) - croppedValue = croppedValue.replace(/\n.*$/g, ''); + let croppedValue = value; + if (value.substring) + croppedValue = value.substring(0, 1024); + if (croppedValue.length < value.length) + croppedValue = croppedValue.replace(/\n.*$/g, ''); super.addField(name, croppedValue); } } diff --git a/lib/WebLib.js b/lib/WebLib.js index 1713438..6bbcc96 100644 --- a/lib/WebLib.js +++ b/lib/WebLib.js @@ -472,5 +472,6 @@ class LogEntry { this.message = entry.message; this.timestamp = entry.timestamp; this.level = entry.level; + this.module = entry.module || entry.m || 'DEFAULT'; } } diff --git a/lib/api/graphql/AnilistApi/Fragments.yaml b/lib/api/graphql/AnilistApi/Fragments.yaml index bef54d0..ed844da 100644 --- a/lib/api/graphql/AnilistApi/Fragments.yaml +++ b/lib/api/graphql/AnilistApi/Fragments.yaml @@ -34,6 +34,18 @@ mediaAdditionalMetadata: | } } +staffFields: | + fragment staffFields on Media { + staff { + edges { + node { + ...staffMetadata + } + role + } + } + } + staffMetadata: | fragment staffMetadata on Staff { id @@ -49,15 +61,3 @@ staffMetadata: | language siteUrl } - -staffFields: | - fragment staffFields on Media { - staff { - edges { - node { - ...staffMetadata - } - role - } - } - } diff --git a/lib/api/graphql/schema.gql b/lib/api/graphql/schema.gql index 1ba4323..bd14138 100644 --- a/lib/api/graphql/schema.gql +++ b/lib/api/graphql/schema.gql @@ -73,6 +73,7 @@ type LogEntry { message: String level: String timestamp: String + module: String } type Query { client: Client diff --git a/lib/commands/ServerUtilityCommands/index.js b/lib/commands/ServerUtilityCommands/index.js index 92dcb8c..dc833fb 100644 --- a/lib/commands/ServerUtilityCommands/index.js +++ b/lib/commands/ServerUtilityCommands/index.js @@ -54,7 +54,7 @@ class ServerUtilityCommandModule extends cmdLib.CommandModule { .replace(/;/g, '\\;'); sequenceString = sequenceString .replace(/"/g, '') - .replace("'", '"'); + .replace(/'/g, '"'); let sequence = this._messageHandler.parseSyntaxString(sequenceString); let execCommand = this._config.prefix + this.template.execute.name; let maxSqPar = this._config.commandSettings.maxSequenceParallel; diff --git a/lib/logging.js b/lib/logging.js index 6cfc1e2..2278909 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -93,26 +93,26 @@ class ModuleLogger { } silly(msg, meta) { - logger.silly(msg, {m: this.logName, ...meta}); + logger.silly(msg, {module: this.logName, ...meta}); } debug(msg, meta) { - logger.debug(msg, {m: this.logName, ...meta}); + logger.debug(msg, {module: this.logName, ...meta}); } verbose(msg, meta) { - logger.verbose(msg, {m: this.logName, ...meta}); + logger.verbose(msg, {module: this.logName, ...meta}); } info(msg, meta) { - logger.info(msg, {m: this.logName, ...meta}); + logger.info(msg, {module: this.logName, ...meta}); } warn(msg, meta) { - logger.warn(msg, {m: this.logName, ...meta}); + logger.warn(msg, {module: this.logName, ...meta}); } error(msg, meta) { - logger.error(msg, {m: this.logName, ...meta}); + logger.error(msg, {module: this.logName, ...meta}); } } diff --git a/web/http/scripts/query.js b/web/http/scripts/query.js index 90660a3..5106bce 100644 --- a/web/http/scripts/query.js +++ b/web/http/scripts/query.js @@ -240,6 +240,7 @@ function queryLogs(count) { level message timestamp + module } }`; postQuery(query).then((res) => { @@ -256,6 +257,10 @@ function queryLogs(count) { lvlSpan.innerText = logEntry.level; lvlSpan.setAttribute('class', 'text-left'); infoDiv.appendChild(lvlSpan); + let moduleSpan = document.createElement('span'); + moduleSpan.innerText = logEntry.module; + moduleSpan.setAttribute('class', 'text-left'); + infoDiv.appendChild(moduleSpan); let tsSpan = document.createElement('span'); tsSpan.setAttribute('timestamp', logEntry.timestamp); tsSpan.innerText = moment(logEntry.timestamp, 'YY-MM-DD-HH-mm-ss').format('MMM Do HH:mm:ss');