Skip to content

Commit

Permalink
Revert "Updated Code to add other LogLevel Methods #39"
Browse files Browse the repository at this point in the history
This reverts commit 82478ab.
  • Loading branch information
TanmoySG authored Jun 17, 2022
1 parent 621e5c6 commit 12a4015
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
9 changes: 2 additions & 7 deletions libraries/js/logsmith/lib/logUtility.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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)
)
}
Expand Down
35 changes: 9 additions & 26 deletions libraries/js/logsmith/logsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
})
}

}

}

0 comments on commit 12a4015

Please sign in to comment.