Improve Discord logging

This commit is contained in:
Jordan Eldredge 2019-10-10 09:32:12 -04:00
parent f526e4ba39
commit 9ca10abdb4

View file

@ -7,8 +7,17 @@ class DiscordWinstonTransport extends Transport {
}
async log(info, callback) {
const { message } = info;
await this._channel.send(`${message}`);
const { message, ...rest } = info;
let dataString = null;
try {
dataString = JSON.stringify(rest, null, 2);
} catch (e) {
dataString = "COULD NOT STRINGIFY DATA";
}
await this._channel.send(`${message}
\`\`\`
${dataString}
\`\`\``);
// Perform the writing to the remote service
callback();
}