From ce592d5cc153ebe1fa2189df26b25528eb09a155 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 26 Sep 2023 20:46:23 +0100 Subject: [PATCH] Port database functions to new logger Signed-off-by: Fred Boniface --- src/services/dbAccess.services.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/dbAccess.services.js b/src/services/dbAccess.services.js index d041eb5..6a3b745 100644 --- a/src/services/dbAccess.services.js +++ b/src/services/dbAccess.services.js @@ -1,5 +1,6 @@ /* global process */ const log = require("../utils/logs.utils"); // Log Helper +const logger = require("../utils/logger.utils"); // New Logger const dbUser = process.env.OWL_DB_USER || "owl"; const dbPass = process.env.OWL_DB_PASS || "twittwoo"; @@ -15,17 +16,16 @@ const db = client.db(dbName); async function query(collection, query, returnId = false) { await client.connect(); - log.out(`dbAccess.query: Connecting to collection: '${collection}'`, "info"); + logger.logger.debug(`dbAccess.query: Connecting to collection: '${collection}'`) var qcoll = db.collection(collection); var qcursor = qcoll.find(query); if (!returnId) { qcursor.project({ _id: 0 }); } - log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`, "info"); + logger.logger.debug(query, "dbAccess.query: Runnung Query") increment(collection); - log.out("dbAccess.query: Query response:"); let result = await qcursor.toArray(); - console.log(result); + logger.logger.debug(result, "dbAccess.query: Response"); return result; } @@ -56,7 +56,7 @@ async function queryAggregate(collection, pipeline) { } async function increment(target) { - log.out(`dbAccess.increment: Incrementing counter for: ${target}`, "info"); + logger.logger.debug(`dbAccess.increment: Incrementing counter for: ${target}`) await client.connect(); let col = db.collection("meta"); let update = {};