From e1b0368d5125952e374ef596fe62ab4533743027 Mon Sep 17 00:00:00 2001 From: Tanmoy Sen Gupta Date: Tue, 17 May 2022 04:44:35 +0000 Subject: [PATCH] Added a Custom LogLevel LOG function #39 --- libraries/js/logsmith/logsmith.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libraries/js/logsmith/logsmith.js b/libraries/js/logsmith/logsmith.js index 7433010..52c1ab7 100644 --- a/libraries/js/logsmith/logsmith.js +++ b/libraries/js/logsmith/logsmith.js @@ -18,7 +18,8 @@ const ChalkLog = { INFO: chalk.blue, CRITICAL: chalk.bgRed.gray, SUCCESS: chalk.green, - FAILURE: chalk.red + FAILURE: chalk.red, + CUSTOM: chalk.whiteBright } const LogLevels = { @@ -26,11 +27,10 @@ const LogLevels = { INFO: "INFO", CRITICAL: "CRITICAL", SUCCESS: "SUCCESS", - FAILURE: "FAILURE" + FAILURE: "FAILURE", + CUSTOM: "CUSTOM" } - - export default class Logsmith { constructor(options, statement) { this.env = options.env || "default" @@ -96,4 +96,13 @@ export default class Logsmith { } } + LOG(loglevel, log) { + loglevel = loglevel.toUpperCase().substring(0,8); + if (this.logFormat == LogFormats.JSON) { + prepareJSONLog(loglevel, log, this.env, function (JSONLog) { + consoleLogJSON(loglevel, ChalkLog.CUSTOM, JSONLog) + }) + } + } + } \ No newline at end of file