From 47447088a22b3a0c536e92f78edd60534306027d Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 16 Mar 2023 20:22:18 +0000 Subject: [PATCH] Add log level (optionally) to log.utils --- src/utils/log.utils.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/log.utils.js b/src/utils/log.utils.js index de25c66..8a67762 100644 --- a/src/utils/log.utils.js +++ b/src/utils/log.utils.js @@ -1,6 +1,12 @@ -async function out(msg) { - var time = new Date().toISOString(); - console.log(`${time} - ${msg}`) +const environment = process.env.NODE_ENV; + +async function out(msg, level = 'OTHR') { + if (environment === "production" && level === "info") { + return; + } else { + const time = new Date().toISOString(); + console.log(`${time} - - ${level.toUpperCase()} - ${msg}`); + } } module.exports = {