Switching to logger.

This commit is contained in:
ThePendulum 2020-01-10 04:40:41 +01:00
parent 68db552e37
commit 89afc5e169
2 changed files with 6 additions and 5 deletions

View File

@ -120,7 +120,7 @@ async function fetchPhoto(photoUrl, index, label, attempt = 1) {
throw new Error(`Response ${res.statusCode} not OK`);
} catch (error) {
console.warn(`Failed attempt ${attempt}/3 to fetch photo ${index + 1} for ${label} (${photoUrl}): ${error}`);
logger.warn(`Failed attempt ${attempt}/3 to fetch photo ${index + 1} for ${label} (${photoUrl}): ${error}`);
if (attempt < 3) {
await Promise.delay(1000);
@ -171,7 +171,7 @@ async function storePhotos(photos, {
primaryRole, // role to assign to first photo if not already in database, used mainly for avatars
}, label) {
if (!photos || photos.length === 0) {
console.warn(`No ${role}s available for ${label}`);
logger.info(`No ${role}s available for ${label}`);
return;
}
@ -273,7 +273,7 @@ async function storeTrailer(trailers, {
: trailers;
if (!trailer || !trailer.src) {
console.warn(`No trailer available for ${label}`);
logger.info(`No trailer available for ${label}`);
return;
}

View File

@ -2,6 +2,7 @@
const config = require('config');
const logger = require('./logger');
const argv = require('./argv');
const knex = require('./knex');
const whereOr = require('./utils/where-or');
@ -102,7 +103,7 @@ async function fetchSitesFromArgv() {
.leftJoin('networks', 'sites.network_id', 'networks.id');
const curatedSites = await curateSites(rawSites, true);
console.log(`Found ${curatedSites.length} sites in database`);
logger.info(`Found ${curatedSites.length} sites in database`);
return sitesByNetwork(curatedSites);
}
@ -120,7 +121,7 @@ async function fetchSitesFromConfig() {
.leftJoin('networks', 'sites.network_id', 'networks.id');
const curatedSites = await curateSites(rawSites, true);
console.log(`Found ${curatedSites.length} sites in database`);
logger.info(`Found ${curatedSites.length} sites in database`);
return sitesByNetwork(curatedSites);
}