Merge pull request #2732 from matrix-org/travis/rageshake-errors

Convert objects and such to usable strings in rageshake
This commit is contained in:
Travis Ralston 2019-03-01 10:20:23 -07:00 committed by GitHub
commit 593bd8ff66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,6 +71,18 @@ class ConsoleLogger {
log(level, ...args) {
// We don't know what locale the user may be running so use ISO strings
const ts = new Date().toISOString();
// Convert objects and errors to helpful things
args = args.map((arg) => {
if (arg instanceof Error) {
return arg.message + (arg.stack ? `\n${arg.stack}` : '');
} else if (typeof(arg) === 'object') {
return JSON.stringify(arg);
} else {
return arg;
}
});
// Some browsers support string formatting which we're not doing here
// so the lines are a little more ugly but easy to implement / quick to
// run.