File Logger
This commit is contained in:
parent
70926ed2ff
commit
760c7e4fd0
@ -80,7 +80,7 @@
|
||||
worker.progress = 0
|
||||
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
|
||||
this.worker = worker
|
||||
worker.postMessage(['scanapt', this.$store.state.Settings.settings.flightgearDirectory_apt])
|
||||
worker.postMessage(['scanapt', this.$store.state.Settings.settings.flightgearDirectory_apt, this.$store.state.Settings.settings.scanLogging])
|
||||
this.pollData()
|
||||
// the reply
|
||||
var store = this.$store
|
||||
@ -127,7 +127,7 @@
|
||||
worker.progress = 0
|
||||
|
||||
this.worker = worker
|
||||
worker.postMessage(['scan', this.$store.state.Settings.settings.airportsDirectory])
|
||||
worker.postMessage(['scan', this.$store.state.Settings.settings.airportsDirectory, this.$store.state.Settings.settings.scanLogging])
|
||||
this.pollData()
|
||||
// the reply
|
||||
var store = this.$store
|
||||
@ -174,7 +174,7 @@
|
||||
worker.max = this.max
|
||||
worker.progress = this.progress
|
||||
this.worker = worker
|
||||
worker.postMessage(['scanai', this.$store.state.Settings.settings.flightgearDirectory_traffic])
|
||||
worker.postMessage(['scanai', this.$store.state.Settings.settings.flightgearDirectory_traffic, this.$store.state.Settings.settings.scanLogging])
|
||||
this.pollData()
|
||||
// the reply
|
||||
var store = this.$store
|
||||
|
@ -82,6 +82,22 @@
|
||||
</el-popover>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="7">
|
||||
<span class="label">Scan logging :</span>
|
||||
</el-col>
|
||||
<el-col :span="15">
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="Logging"
|
||||
width="200"
|
||||
trigger="hover"
|
||||
content="Switch on logging for scan. Big performance hit"
|
||||
>
|
||||
<el-switch v-model="scanLogging" slot="reference"></el-switch>
|
||||
</el-popover>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="7" class="label"></el-col>
|
||||
<el-col :span="17">
|
||||
@ -184,6 +200,16 @@
|
||||
},
|
||||
test_directory: function () {
|
||||
return this.$store.state.Settings.settings.testDirectory
|
||||
},
|
||||
scanLogging: {
|
||||
// getter
|
||||
get: function () {
|
||||
return this.$store.state.Settings.settings.scanLogging === 1
|
||||
},
|
||||
// setter
|
||||
set: function (newValue) {
|
||||
this.$store.commit('SET_SCAN_LOGGING', newValue ? 1 : 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ const mutations = {
|
||||
'SET_PHI_URL' (state, phi_url) {
|
||||
state.settings.phi_url = phi_url
|
||||
},
|
||||
'SET_SCAN_LOGGING' (state, scanLogging) {
|
||||
state.settings.scanLogging = scanLogging
|
||||
},
|
||||
'ADD_WIP' (state, airport) {
|
||||
const item = state.wip.find((e) => e.icao === airport.icao)
|
||||
airport.time = Date.now()
|
||||
|
@ -1,4 +1,4 @@
|
||||
var util = require("util")
|
||||
var util = require("util");
|
||||
|
||||
const d = new Date();
|
||||
|
||||
@ -10,12 +10,20 @@ const fName = 'scan_' + d.getFullYear()
|
||||
+ d.getSeconds()
|
||||
+ d.getMilliseconds() + '.log';
|
||||
|
||||
var logStream = require('fs').createWriteStream( fName, {autoClose: true});
|
||||
var logStream = null;
|
||||
|
||||
var loggerInit = function (logging) {
|
||||
if (logging) {
|
||||
logStream = require('fs').createWriteStream( fName, {autoClose: true});
|
||||
}
|
||||
}
|
||||
|
||||
var logger = function (level, msg, o) {
|
||||
var d = new Date();
|
||||
//logStream.write(d.toUTCString() + '|' + level + ' | ' + msg + '\r\n');
|
||||
if (o != undefined) {
|
||||
//logStream.write( util.inspect(o,{depth: 2}) + '\r\n');
|
||||
if(logStream!==null) {
|
||||
logStream.write(d.toUTCString() + '|' + level + ' | ' + msg + '\r\n');
|
||||
}
|
||||
if (o != undefined && logStream!==null) {
|
||||
logStream.write( util.inspect(o,{depth: 2}) + '\r\n');
|
||||
}
|
||||
}
|
@ -19,9 +19,10 @@ function errorReceiver(event) {
|
||||
|
||||
onmessage = function (event) {
|
||||
postMessage('scanStarted');
|
||||
logger('info', 'Scan Started');
|
||||
console.log(event.data);
|
||||
if (event.data[0] === 'scan') {
|
||||
loggerInit(event.data[2]);
|
||||
logger('info', 'Scan Groundnet Started');
|
||||
scanGroundnet(event.data[1]).then(result => {
|
||||
console.log("DONE Scanning");
|
||||
postMessage('DONE');
|
||||
@ -30,9 +31,13 @@ onmessage = function (event) {
|
||||
).catch(result => {
|
||||
console.log('Crashed');
|
||||
console.log(result);
|
||||
logger('error', 'crashed');
|
||||
logger('error', result);
|
||||
postMessage('DONE');
|
||||
});
|
||||
} else if (event.data[0] === 'scanai') {
|
||||
loggerInit(event.data[2]);
|
||||
logger('info', 'Scan AI Started');
|
||||
scanai(event.data[1]).then(result => {
|
||||
console.log("DONE Scanning");
|
||||
postMessage('DONE');
|
||||
@ -41,10 +46,14 @@ onmessage = function (event) {
|
||||
).catch(result => {
|
||||
console.log('Crashed');
|
||||
console.log(result);
|
||||
logger('error', 'crashed');
|
||||
logger('error', result);
|
||||
postMessage('DONE');
|
||||
});
|
||||
}
|
||||
else if (event.data[0] === 'scanapt') {
|
||||
loggerInit(event.data[2]);
|
||||
logger('info', 'Scan APT Started');
|
||||
scanAPT(event.data[1]).then(result => {
|
||||
console.log("DONE Scanning");
|
||||
postMessage('DONE');
|
||||
@ -53,6 +62,8 @@ onmessage = function (event) {
|
||||
).catch(result => {
|
||||
console.log('Crashed');
|
||||
console.log(result);
|
||||
logger('error', 'crashed');
|
||||
logger('error', result);
|
||||
postMessage('DONE');
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user