Bug Fixes

- fixed ExtendedRichEmbed bug for string.substring if the method doesn't exist on the value
- added log module information to webinterface logs
- changed logging meta module info from `m` to `module`
pull/51/head
Trivernis 6 years ago
parent 169d83fccf
commit 5fdbe40c88

@ -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 interface to fit the new graphql schema
- changed module export definition to `Object.assign(exports, {...})` at the end of the module file - changed module export definition to `Object.assign(exports, {...})` at the end of the module file
- added section `commandSettings` to config.js file - added section `commandSettings` to config.js file
- added module information to webinterface log
### Removed ### Removed
- removed lib/cmd because all functionalities are now adapted to the MessageHandler and CommadnHandlers - removed lib/cmd because all functionalities are now adapted to the MessageHandler and CommadnHandlers

@ -246,19 +246,19 @@ class Bot {
// Executing the main function // Executing the main function
if (typeof require !== 'undefined' && require.main === module) { if (typeof require !== 'undefined' && require.main === module) {
let logger = logging.logger; let logger = new logging.Logger('MAIN-init');
logger.info("Starting up... ", {m: 'bot.init'}); logger.info("Starting up... ");
logger.debug('Calling constructor...', {m: 'bot.init'}); logger.debug('Calling constructor...');
let discordBot = new Bot(); let discordBot = new Bot();
logger.debug('Initializing services...', {m: 'bot.init'}); logger.debug('Initializing services...');
discordBot.initServices().then(() => { discordBot.initServices().then(() => {
logger.debug('Starting Bot...', {m: 'bot.init'}); logger.debug('Starting Bot...');
discordBot.start().catch((err) => { //eslint-disable-line promise/no-nesting discordBot.start().catch((err) => { //eslint-disable-line promise/no-nesting
logger.error(err.message, {m: 'bot.init'}); logger.error(err.message);
logger.debug(err.stack, {m: 'bot.init'}); logger.debug(err.stack);
}); });
}).catch((err) => { }).catch((err) => {
logger.error(err.message, {m: 'bot.init'}); logger.error(err.message);
logger.debug(err.stack, {m: 'bot.init'}); logger.debug(err.stack);
}); });
} }

@ -247,7 +247,9 @@ class ExtendedRichEmbed extends Discord.RichEmbed {
* @param value * @param value
*/ */
setDescription(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) if (croppedValue.length < value.length)
croppedValue = croppedValue.replace(/\n.*$/g, ''); croppedValue = croppedValue.replace(/\n.*$/g, '');
super.setDescription(croppedValue); super.setDescription(croppedValue);
@ -259,7 +261,9 @@ class ExtendedRichEmbed extends Discord.RichEmbed {
* @param value * @param value
*/ */
addField(name, value) { addField(name, value) {
let croppedValue = value.substring(0, 1024); let croppedValue = value;
if (value.substring)
croppedValue = value.substring(0, 1024);
if (croppedValue.length < value.length) if (croppedValue.length < value.length)
croppedValue = croppedValue.replace(/\n.*$/g, ''); croppedValue = croppedValue.replace(/\n.*$/g, '');
super.addField(name, croppedValue); super.addField(name, croppedValue);

@ -472,5 +472,6 @@ class LogEntry {
this.message = entry.message; this.message = entry.message;
this.timestamp = entry.timestamp; this.timestamp = entry.timestamp;
this.level = entry.level; this.level = entry.level;
this.module = entry.module || entry.m || 'DEFAULT';
} }
} }

@ -34,6 +34,18 @@ mediaAdditionalMetadata: |
} }
} }
staffFields: |
fragment staffFields on Media {
staff {
edges {
node {
...staffMetadata
}
role
}
}
}
staffMetadata: | staffMetadata: |
fragment staffMetadata on Staff { fragment staffMetadata on Staff {
id id
@ -49,15 +61,3 @@ staffMetadata: |
language language
siteUrl siteUrl
} }
staffFields: |
fragment staffFields on Media {
staff {
edges {
node {
...staffMetadata
}
role
}
}
}

@ -73,6 +73,7 @@ type LogEntry {
message: String message: String
level: String level: String
timestamp: String timestamp: String
module: String
} }
type Query { type Query {
client: Client client: Client

@ -54,7 +54,7 @@ class ServerUtilityCommandModule extends cmdLib.CommandModule {
.replace(/;/g, '\\;'); .replace(/;/g, '\\;');
sequenceString = sequenceString sequenceString = sequenceString
.replace(/"/g, '') .replace(/"/g, '')
.replace("'", '"'); .replace(/'/g, '"');
let sequence = this._messageHandler.parseSyntaxString(sequenceString); let sequence = this._messageHandler.parseSyntaxString(sequenceString);
let execCommand = this._config.prefix + this.template.execute.name; let execCommand = this._config.prefix + this.template.execute.name;
let maxSqPar = this._config.commandSettings.maxSequenceParallel; let maxSqPar = this._config.commandSettings.maxSequenceParallel;

@ -93,26 +93,26 @@ class ModuleLogger {
} }
silly(msg, meta) { silly(msg, meta) {
logger.silly(msg, {m: this.logName, ...meta}); logger.silly(msg, {module: this.logName, ...meta});
} }
debug(msg, meta) { debug(msg, meta) {
logger.debug(msg, {m: this.logName, ...meta}); logger.debug(msg, {module: this.logName, ...meta});
} }
verbose(msg, meta) { verbose(msg, meta) {
logger.verbose(msg, {m: this.logName, ...meta}); logger.verbose(msg, {module: this.logName, ...meta});
} }
info(msg, meta) { info(msg, meta) {
logger.info(msg, {m: this.logName, ...meta}); logger.info(msg, {module: this.logName, ...meta});
} }
warn(msg, meta) { warn(msg, meta) {
logger.warn(msg, {m: this.logName, ...meta}); logger.warn(msg, {module: this.logName, ...meta});
} }
error(msg, meta) { error(msg, meta) {
logger.error(msg, {m: this.logName, ...meta}); logger.error(msg, {module: this.logName, ...meta});
} }
} }

@ -240,6 +240,7 @@ function queryLogs(count) {
level level
message message
timestamp timestamp
module
} }
}`; }`;
postQuery(query).then((res) => { postQuery(query).then((res) => {
@ -256,6 +257,10 @@ function queryLogs(count) {
lvlSpan.innerText = logEntry.level; lvlSpan.innerText = logEntry.level;
lvlSpan.setAttribute('class', 'text-left'); lvlSpan.setAttribute('class', 'text-left');
infoDiv.appendChild(lvlSpan); 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'); let tsSpan = document.createElement('span');
tsSpan.setAttribute('timestamp', logEntry.timestamp); tsSpan.setAttribute('timestamp', logEntry.timestamp);
tsSpan.innerText = moment(logEntry.timestamp, 'YY-MM-DD-HH-mm-ss').format('MMM Do HH:mm:ss'); tsSpan.innerText = moment(logEntry.timestamp, 'YY-MM-DD-HH-mm-ss').format('MMM Do HH:mm:ss');

Loading…
Cancel
Save