From 89afc5e16942689b8760914c25a5268d05de8ac9 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 10 Jan 2020 04:40:41 +0100 Subject: [PATCH] Switching to logger. --- src/media.js | 6 +++--- src/sites.js | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/media.js b/src/media.js index 6dfb3f9a..374e9f27 100644 --- a/src/media.js +++ b/src/media.js @@ -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; } diff --git a/src/sites.js b/src/sites.js index d64be7d1..49d987ea 100644 --- a/src/sites.js +++ b/src/sites.js @@ -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); }