Files
Zumri-Backend/app/utils/consoleLog.utill.js
Sathira Sri Sathara b6b345f245 feat: Implement Phase 2 cross-cutting services with email and notification enhancements
- Refactor email verification and password reset utilities to use new email service.
- Introduce email delivery queue and notification delivery model for better tracking.
- Enhance file validation and storage services for improved security and ownership management.
- Add cron job for cleaning inactive notifications with retention policy.
- Update document worker to handle document generation and storage more efficiently.
- Implement logging improvements in activity and log workers.
- Create comprehensive documentation for new API endpoints and services.
- Add unit tests for file validation and notification policies to ensure robustness.
2026-09-03 14:22:34 +05:30

54 lines
1.1 KiB
JavaScript

/**
* Copyright (c) 2026 Niolla
* All rights reserved.
*
* This source code is proprietary and confidential.
* Unauthorized copying, modification, distribution, or use
* of this file, via any medium, is strictly prohibited.
*/
// app/utils/consoleLog.util.js
const isDevelopment = process.env.NODE_ENV === "development";
const logQueue = require("../queues/log.queue");
const log = async (...args) => {
if (isDevelopment) {
console.log(...args);
return;
}
try {
const message = args
.map((arg) => {
if (arg instanceof Error) {
return arg.message;
}
if (typeof arg === "object") {
return JSON.stringify(arg, (key, value) => /password|otp|token|authorization|cookie|secret/i.test(key) ? "[REDACTED]" : value);
}
return String(arg);
})
.join(" ");
await logQueue.add("log", {
level: "info", service: "zumri-api", message,
timestamp: new Date().toISOString(),
});
} catch (err) {
console.error("Log queue failed:", err);
}
};
function runningEnvironment() {
return !isDevelopment;
}
module.exports = {
log,
runningEnvironment,
};