Fix logger crashing the extension
This commit is contained in:
parent
f1d2881359
commit
f3e5aeb9e6
@ -3,22 +3,6 @@ import currentBrowser from '../conf/BrowserDetect';
|
||||
|
||||
class Logger {
|
||||
constructor(conf) {
|
||||
this.initLogger();
|
||||
if (conf && process.env.CHANNEL === 'dev') {
|
||||
this.conf = conf;
|
||||
}
|
||||
if (this.conf.consoleOptions === undefined) {
|
||||
this.conf.consoleOptions = {};
|
||||
}
|
||||
if (!this.conf.fileOptions === undefined) {
|
||||
this.conf.fileOptions = {};
|
||||
}
|
||||
this.isBackgroundPage = !!conf.isBackgroundPage;
|
||||
this.history = [];
|
||||
this.globalHistory = {};
|
||||
this.startTime = performance.now();
|
||||
this.temp_disable = false;
|
||||
this.stopTime = conf.timeout ? performance.now() + (conf.timeout * 1000) : undefined;
|
||||
}
|
||||
|
||||
static saveConfig(conf) {
|
||||
@ -66,7 +50,28 @@ class Logger {
|
||||
}
|
||||
}
|
||||
|
||||
initLogger() {
|
||||
async init(conf) {
|
||||
if (conf && process.env.CHANNEL === 'dev') {
|
||||
this.conf = conf;
|
||||
} else {
|
||||
this.conf = await Logger.getConfig();
|
||||
}
|
||||
if (this.conf.consoleOptions === undefined) {
|
||||
this.conf.consoleOptions = {};
|
||||
}
|
||||
if (!this.conf.fileOptions === undefined) {
|
||||
this.conf.fileOptions = {};
|
||||
}
|
||||
// this is the only property that always gets passed via conf
|
||||
// and doesn't get ignored even if the rest of the conf gets
|
||||
// loaded from browser storage
|
||||
this.isBackgroundPage = !!conf.isBackgroundPage;
|
||||
this.history = [];
|
||||
this.globalHistory = {};
|
||||
this.startTime = performance.now();
|
||||
this.temp_disable = false;
|
||||
this.stopTime = conf.timeout ? performance.now() + (conf.timeout * 1000) : undefined;
|
||||
|
||||
const ths = this;
|
||||
const br = currentBrowser.firefox ? browser : chrome;
|
||||
br.storage.onChanged.addListener( (changes, area) => {
|
||||
@ -81,14 +86,8 @@ class Logger {
|
||||
}
|
||||
});
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
async init() {
|
||||
if (!this.conf) {
|
||||
this.conf = await this.getSaved();
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.log = [];
|
||||
|
@ -31,13 +31,14 @@ class UWServer {
|
||||
|
||||
async setup() {
|
||||
// logger is the first thing that goes up
|
||||
this.logger = new Logger({
|
||||
allowLogging: true,
|
||||
logToFile: false,
|
||||
logToConsole: true,
|
||||
logAll: true,
|
||||
});
|
||||
await this.logger.init();
|
||||
const loggingOptions = {
|
||||
allowLogging: true,
|
||||
logToFile: false,
|
||||
logToConsole: true,
|
||||
logAll: true,
|
||||
};
|
||||
this.logger = new Logger();
|
||||
await this.logger.init(loggingOptions);
|
||||
|
||||
this.settings = new Settings({logger: this.logger});
|
||||
await this.settings.init();
|
||||
|
@ -52,23 +52,24 @@ class UW {
|
||||
},
|
||||
consoleOptions: {
|
||||
enabled: true, // if logging is enabled at all
|
||||
// 'debug': true,
|
||||
// 'init': true,
|
||||
// 'settings': true,
|
||||
// 'keyboard': true,
|
||||
// 'mousemove': false,
|
||||
// 'actionHandler': false,
|
||||
// 'comms': false,
|
||||
// 'playerDetect': false,
|
||||
// 'resizer': true,
|
||||
// 'scaler': true,
|
||||
// 'stretcher': true,
|
||||
// 'videoRescan': false,
|
||||
// 'arDetect': true,
|
||||
// 'arDetect_verbose': true,
|
||||
'debug': true,
|
||||
'init': true,
|
||||
'settings': true,
|
||||
'keyboard': true,
|
||||
'mousemove': false,
|
||||
'actionHandler': false,
|
||||
'comms': false,
|
||||
'playerDetect': false,
|
||||
'resizer': true,
|
||||
'scaler': true,
|
||||
'stretcher': true,
|
||||
'videoRescan': false,
|
||||
'arDetect': true,
|
||||
'arDetect_verbose': true,
|
||||
}
|
||||
};
|
||||
this.logger = new Logger(loggingOptions);
|
||||
this.logger = new Logger();
|
||||
await this.logger.init(loggingOptions);
|
||||
// await this.logger.init(); // not needed if logging options are provided at creation
|
||||
}
|
||||
} catch (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user