From 12a40152927b3af9a22ed0330feb336f6772e14a Mon Sep 17 00:00:00 2001 From: Tanmoy Sen Gupta Date: Fri, 17 Jun 2022 19:14:56 +0530 Subject: [PATCH] Revert "Updated Code to add other LogLevel Methods #39" This reverts commit 82478ab165e84a7abc3f0154d489de424718f26a. --- libraries/js/logsmith/lib/logUtility.js | 9 ++----- libraries/js/logsmith/logsmith.js | 35 +++++++------------------ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/libraries/js/logsmith/lib/logUtility.js b/libraries/js/logsmith/lib/logUtility.js index 1295697..f7082e7 100644 --- a/libraries/js/logsmith/lib/logUtility.js +++ b/libraries/js/logsmith/lib/logUtility.js @@ -1,10 +1,6 @@ import chalk from 'chalk'; import format from 'string-template'; -function formatLogLevel(loglevel){ - return loglevel.padEnd(8) -} - export function prepareJSONLog(logLevel, log, env, callback) { const JSONLog = { @@ -16,10 +12,9 @@ export function prepareJSONLog(logLevel, log, env, callback) { callback(JSONLog) } -export function consoleLogJSON(loglevel, chalkMode, JSONLog){ - loglevel = formatLogLevel(loglevel) +export function consoleLogJSON(chalkMode, JSONLog){ console.log( - chalkMode(`[${loglevel}]`), + chalkMode(`[${JSONLog.logLevel}]`), JSON.stringify(JSONLog) ) } diff --git a/libraries/js/logsmith/logsmith.js b/libraries/js/logsmith/logsmith.js index 7433010..eb1fc7d 100644 --- a/libraries/js/logsmith/logsmith.js +++ b/libraries/js/logsmith/logsmith.js @@ -6,13 +6,13 @@ import { readConfigFile } from './lib/fetchConfigs.js'; import { JSONLogDriver } from './lib/drivers.js'; import { consoleLogJSON, prepareJSONLog } from './lib/logUtility.js'; -const defaultLogPrintPattern = "[{level}] {body}" - const LogFormats = { JSON: "json", STATEMENT: "statement" } +const defaultLogPrintPattern = "[{level}] {body}" + const ChalkLog = { WARN: chalk.yellowBright, INFO: chalk.blue, @@ -55,45 +55,28 @@ export default class Logsmith { } } - INFO(log) { - if (this.logFormat == LogFormats.JSON) { - prepareJSONLog(LogLevels.INFO, log, this.env, function (JSONLog) { - consoleLogJSON(LogLevels.INFO, ChalkLog.INFO, JSONLog) - }) - } - } - WARN(log) { if (this.logFormat == LogFormats.JSON) { prepareJSONLog(LogLevels.WARN, log, this.env, function (JSONLog) { - consoleLogJSON(LogLevels.WARN, ChalkLog.WARN, JSONLog) + consoleLogJSON(ChalkLog.WARN, JSONLog) }) } } + INFO(log) { + + } CRITICAL(log) { - if (this.logFormat == LogFormats.JSON) { - prepareJSONLog(LogLevels.CRITICAL, log, this.env, function (JSONLog) { - consoleLogJSON(LogLevels.CRITICAL, ChalkLog.CRITICAL, JSONLog) - }) - } + } SUCCESS(log) { - if (this.logFormat == LogFormats.JSON) { - prepareJSONLog(LogLevels.SUCCESS, log, this.env, function (JSONLog) { - consoleLogJSON(LogLevels.SUCCESS, ChalkLog.SUCCESS, JSONLog) - }) - } + } FAILURE(log) { - if (this.logFormat == LogFormats.JSON) { - prepareJSONLog(LogLevels.FAILURE, log, this.env, function (JSONLog) { - consoleLogJSON(LogLevels.FAILURE, ChalkLog.FAILURE, JSONLog) - }) - } + } } \ No newline at end of file