diff --git a/Server/db/models/PageSpeedCheck.js b/Server/db/models/PageSpeedCheck.js index a7c013f93..344cc685d 100644 --- a/Server/db/models/PageSpeedCheck.js +++ b/Server/db/models/PageSpeedCheck.js @@ -1,4 +1,5 @@ import mongoose from "mongoose"; +import logger from "../../utils/logger.js"; const AuditSchema = mongoose.Schema({ id: { type: String, required: true }, title: { type: String, required: true }, @@ -90,19 +91,22 @@ PageSpeedCheck.pre("save", async function (next) { const monitor = await mongoose.model("Monitor").findById(this.monitorId); if (monitor && monitor.status !== this.status) { if (monitor.status === true && this.status === false) { - // TODO issue alert - console.log("Monitor went down"); + logger.info({ message: "Monitor went down", monitorId: monitor._id }); } if (monitor.status === false && this.status === true) { - // TODO issue alert - console.log("Monitor went up"); + logger.info({ message: "Monitor went up", monitorId: monitor._id }); } monitor.status = this.status; await monitor.save(); } } catch (error) { - console.log(error); + logger.error({ + message: error.message, + service: "PageSpeedCheck", + method: "pre-save", + stack: error.stack, + }); } finally { next(); } diff --git a/Server/db/models/User.js b/Server/db/models/User.js index 37ecbcec0..a4d90d44a 100644 --- a/Server/db/models/User.js +++ b/Server/db/models/User.js @@ -1,5 +1,6 @@ import mongoose from "mongoose"; import bcrypt from "bcrypt"; +import logger from "../../utils/logger.js"; const UserSchema = mongoose.Schema( { @@ -81,7 +82,9 @@ UserSchema.methods.comparePassword = async function (submittedPassword) { const User = mongoose.model("User", UserSchema); User.init().then(() => { - console.log("User model initialized"); + logger.info({ + message: "User model initialized", + }); }); export default mongoose.model("User", UserSchema); diff --git a/Server/db/mongo/modules/checkModule.js b/Server/db/mongo/modules/checkModule.js index eb9cc9f5c..2457d7131 100644 --- a/Server/db/mongo/modules/checkModule.js +++ b/Server/db/mongo/modules/checkModule.js @@ -79,7 +79,11 @@ const getChecksCount = async (req) => { checksQuery.statusCode = 5000; break; default: - console.log("default"); + logger.warn({ + message: "invalid filter", + service: SERVICE_NAME, + method: "getChecksCount", + }); break; } } @@ -112,7 +116,7 @@ const getChecks = async (req) => { if (dateRange !== undefined) { checksQuery.createdAt = { $gte: dateRangeLookup[dateRange] }; } - // Fitler checks by status + // Filter checks by status if (filter !== undefined) { checksQuery.status = false; switch (filter) { @@ -124,7 +128,11 @@ const getChecks = async (req) => { checksQuery.statusCode = 5000; break; default: - console.log("default"); + logger.warn({ + message: "invalid filter", + service: SERVICE_NAME, + method: "getChecks", + }); break; } } @@ -172,7 +180,11 @@ const getTeamChecks = async (req) => { checksQuery.statusCode = 5000; break; default: - console.log("default"); + logger.warn({ + message: "invalid filter", + service: SERVICE_NAME, + method: "getTeamChecks", + }); break; } } diff --git a/Server/db/mongo/modules/maintenanceWindowModule.js b/Server/db/mongo/modules/maintenanceWindowModule.js index 4644d90bf..e2488dc3b 100644 --- a/Server/db/mongo/modules/maintenanceWindowModule.js +++ b/Server/db/mongo/modules/maintenanceWindowModule.js @@ -202,7 +202,6 @@ const deleteMaintenanceWindowByUserId = async (userId) => { }; const editMaintenanceWindowById = async (maintenanceWindowId, maintenanceWindowData) => { - console.log(maintenanceWindowData); try { const editedMaintenanceWindow = MaintenanceWindow.findByIdAndUpdate( maintenanceWindowId, diff --git a/Server/service/jobQueue.js b/Server/service/jobQueue.js index bb9457399..51e27fdb2 100644 --- a/Server/service/jobQueue.js +++ b/Server/service/jobQueue.js @@ -260,7 +260,7 @@ class JobQueue { */ async addJob(jobName, payload) { try { - console.log("Adding job", payload?.url ?? "No URL"); + this.logger.info({ message: `Adding job ${payload?.url ?? "No URL"}` }); // Execute job immediately await this.queue.add(jobName, payload); await this.queue.add(jobName, payload, {