Lots of UI updates

This commit is contained in:
2018-08-16 00:13:06 +02:00
parent 38b440e2f6
commit d92bd0c586
24 changed files with 637 additions and 225 deletions

View File

@@ -1,12 +1,3 @@
/* const overrides = [
'log',
];
const proxies = overrides.reduce((output, key) => ({
...output,
[key]: window.console[key],
}), {}); */
const proxyConsole = window.console;
class Log {
@@ -24,41 +15,49 @@ class Log {
this.listeners = this.listeners.filter(l => l !== fn);
}
log(type, data) {
log(type, data, keep) {
const entry = {
type,
data,
};
this.logs.push(entry);
this.listeners.forEach(l => l(entry));
this.listeners.forEach(l => l(this.logs));
if (keep) {
proxyConsole[type](...data);
}
}
info(data) {
this.log('info', data);
info(data, keep) {
this.log('info', data, keep);
}
error(error) {
this.log('error', error);
error(data, keep) {
this.log('error', data, keep);
}
warn(data) {
this.log('warn', data);
warn(data, keep) {
this.log('warn', data, keep);
}
debug(data) {
this.log('debug', data);
debug(data, keep) {
this.log('debug', data, keep);
}
attach(keep) {
const redirected = Object.keys(proxyConsole).reduce((output, key) => ({
...output,
[key]: keep ? (...args) => proxyConsole[key](...args) : () => {},
}), {});
window.console = {
error: (...data) => this.error(...data),
warn: (data) => this.warn(data),
info: (data) => this.info(data),
log: (data) => this.info(data),
debug: (data) => this.debug(data),
...redirected,
error: (...data) => this.error(data, keep),
warn: (...data) => this.warn(data, keep),
info: (...data) => this.info(data, keep),
log: (...data) => this.info(data, keep),
debug: (...data) => this.debug(data, keep),
};
ErrorUtils.setGlobalHandler((err, fatal) => {
this.error(err);
this.error([err], keep);
});
}