mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 04:48:50 +03:00
Convert objects and such to usable strings in rageshake
Fixes https://github.com/vector-im/riot-web/issues/7844
This commit is contained in:
parent
3ce2c3a76d
commit
e1f26059a7
1 changed files with 12 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue