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 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

@ -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);
});
}

@ -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);
}
}

@ -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';
}
}

@ -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
}
}
}

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

@ -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;

@ -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});
}
}

@ -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');

Loading…
Cancel
Save