From 566d3a3e1e6ff12269dee9c31ee257e048037cab Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sat, 19 Mar 2022 23:43:26 -0500 Subject: [PATCH] Add logging for initial database connection --- helpers/db.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helpers/db.js b/helpers/db.js index 4754b42..a68e044 100644 --- a/helpers/db.js +++ b/helpers/db.js @@ -1,5 +1,6 @@ const mongoose = require('mongoose'); +const { log } = require('../helpers/log.js'); const userScore = require('../models/userScore'); module.exports = { @@ -36,6 +37,8 @@ module.exports = { .connect(mongoUri, { useUnifiedTopology: true, useNewUrlParser: true, - }); + }) + .then(() => log({ logger: 'db', content: `Connected to the database at ${mongoUri}!`, level: 'info' })) + .catch(err => log({ logger: 'db', content: `Failed to connect to the database at ${mongoUri}: ${err}`, level: 'fatal' })); }, };