Fixed logger issues

This commit is contained in:
Tamius Han 2019-08-25 22:00:57 +02:00
parent 0918c8b86d
commit e2df9285ff
4 changed files with 41 additions and 14 deletions
src/ext

View File

@ -4,16 +4,14 @@ const _prod = false;
var Debug = {
// performanceMetrics: true, // should not be affected by debug.debug in order to allow benchmarking of the impact logging in console has
// init: true,
// debug: true,
init: true,
debug: true,
// keyboard: true,
// resizer: true,
resizer: true,
// debugArDetect: true,
// scaler: true,
// debugStorage: false,
// debugStorage: true,
// comms: false,
// comms: true,
comms: true,
// showArDetectCanvas: true,
// flushStoredSettings: true,
// flushStoredSettings: false,

View File

@ -68,20 +68,19 @@ class Logger {
if (!this.conf.consoleOptions.enabled || this.temp_disable) {
return false;
}
if (component.length) {
if (Array.isArray(component) && component.length) {
for (const c in component) {
if (this.conf.fileOptions[component]) {
return this.conf.fileOptions[component];
if (this.conf.consoleOptions[component]) {
return this.conf.consoleOptions[component];
}
}
}
return this.conf.fileOptions[component];
return this.conf.consoleOptions[component];
}
// level is unused as of now, but this may change in the future
// levels: 'info', 'warn', 'error'
log(level, component, ...message) {
if (!this.conf) {
return;
}

View File

@ -22,6 +22,8 @@ class PageInfo {
this.logger = logger;
console.log("this.logger:", logger, this.logger)
if (comms){
this.comms = comms;
}
@ -138,7 +140,7 @@ class PageInfo {
const oldVideoCount = this.videos.length;
try{
var vids = this.getVideos(window.location.host);
var vids = this.getVideos(window.location.host);
if(!vids || vids.length == 0){
this.hasVideos = false;
@ -195,7 +197,7 @@ class PageInfo {
} else {
this.logger.log('info', 'videoRescan', "[PageInfo::rescan] found new video candidate:", video, "NOTE:: Video initialization starts here:\n--------------------------------\n")
v = new VideoData(video, this.settings, this, logger);
v = new VideoData(video, this.settings, this, this.logger);
// console.log("[PageInfo::rescan] v is:", v)
v.initArDetection();
this.videos.push(v);

View File

@ -55,8 +55,36 @@ class UW {
await this.settings.init();
}
try {
if (!this.logger) {
this.logger = new Logger(this.settings.getLoggingOptions);
const loggingOptions = {
logToFile: false,
logToConsole: true,
fileOptions: {
// really the same stuff as consoleOptions
},
consoleOptions: {
enabled: true, // if logging is enabled at all
'debug': true,
'init': true,
'keyboard': false,
'mousemove': false,
'actionHandler': false,
'comms': true,
'playerDetect': true,
'resizer': true,
'scaler': true,
'stretcher': true,
'videoRescan': false,
'arDetect': false,
'arDetect_verbose': false,
}
};
// this.logger = new Logger(this.settings.getLoggingOptions);
this.logger = new Logger(loggingOptions);
}
} catch (e) {
console.error("logger init failed!", e)
}
this.comms = new CommsClient('content-client-port', this.settings, this.logger);