Replace console.error with structured logger in recordScraperRun
All checks were successful
CI/CD Pipeline - Apartment API / Send Webhook Notification (pull_request) Successful in 3s
CI/CD Pipeline - Apartment API / Build & Push Image (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Scan Dependencies (pull_request) Successful in 13s
CI/CD Pipeline - Apartment API / Run Linting (pull_request) Successful in 9m36s
CI/CD Pipeline - Apartment API / Run Tests (pull_request) Successful in 9m51s
CI/CD Pipeline - Apartment API / Deploy to Production (pull_request) Has been skipped

Switch error logging from console.error to the injected logger.error
pattern for consistency with the rest of the scraper service layer.
Update tests to verify logger.error is called instead of console.error.
This commit is contained in:
2026-02-06 01:41:50 -07:00
parent 74dc62c53f
commit 48512e01ba
2 changed files with 27 additions and 32 deletions

View File

@ -626,9 +626,10 @@ async function updateDailySummary(db, summaryData, logger) {
*
* @param {Db} db - MongoDB database instance
* @param {Object} runData - Run data to record (jobId, trigger, status, duration, etc.)
* @param {Object} logger - Logger instance
* @returns {Promise<Object|null>} Insert result, or null on failure
*/
async function recordScraperRun(db, runData) {
async function recordScraperRun(db, runData, logger) {
const collection = db.collection(config.COLLECTIONS.SCRAPER_RUNS);
try {
@ -641,7 +642,7 @@ async function recordScraperRun(db, runData) {
} catch (error) {
// Log but don't throw - recording history should not break scraper
console.error('Failed to record scraper run:', error.message);
logger.error('Failed to record scraper run', { errorMessage: error.message });
return null;
}
}