I have a function:
function update_log_file(){
return new Promise(function(resolve, reject){
setInterval(function(){
let logFile = '\\\\network\\sharedfolder\\GG\\' + moment(Date.now()).format('YYMMDD') + 'data_log.txt';
let log_with_batch = {
log: logFile,
batch: 'new'
}
resolve(log_with_batch);
}, 2000);
});
}
and the invoker:
update_log_file().then(function(log_with_batch){
console.log(log_with_batch);
tail = new Tail(log_with_batch.log);
tail.on('line', function(data){
console.log(data)
});
tail.error('error', function(error){
console.log(error)
});
});
How am I able to see the object "log_with_batch" every 2 secs using promises and setInterval?
Please feel free to correct my functions. Thank you!