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