Added logger to ready.js

This commit is contained in:
Christer Warén 2021-08-22 20:50:48 +03:00
parent b979d26425
commit c5f269c0a7

View File

@ -21,19 +21,25 @@ module.exports = {
} }
try { try {
client.funcs.logger('Stations', 'Started fetching list ' + client.config.stationslistUrl);
client.stations = await fetch(client.config.stationslistUrl) client.stations = await fetch(client.config.stationslistUrl)
.then(client.funcs.checkFetchStatus) .then(client.funcs.checkFetchStatus)
.then(response => response.json()); .then(response => response.json());
client.funcs.logger('Stations', 'Successfully fetched list' + "\n");
} catch (error) { } catch (error) {
//console.error(error); client.funcs.logger('Stations', ' Fetching list failed');
console.error(error + "\n");
} }
setInterval(async () => { setInterval(async () => {
try { try {
client.funcs.logger('Stations' + 'Started fetching list ' + client.config.stationslistUrl);
client.stations = await fetch(client.config.stationslistUrl) client.stations = await fetch(client.config.stationslistUrl)
.then(client.funcs.checkFetchStatus) .then(client.funcs.checkFetchStatus)
.then(response => response.json()); .then(response => response.json());
console.log('Stations', 'Successfully fetched list' + "\n");
} catch (error) { } catch (error) {
client.funcs.logger('Stations', 'Fetching list failed');
//console.error(error); //console.error(error);
} }
}, 3600000); }, 3600000);