Skip to content

Commit

Permalink
Added a Custom LogLevel LOG function #39
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmoySG authored May 17, 2022
1 parent a0b1524 commit 1b82e97
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions libraries/js/logsmith/logsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const ChalkLog = {
INFO: chalk.blue,
CRITICAL: chalk.bgRed.gray,
SUCCESS: chalk.green,
FAILURE: chalk.red
FAILURE: chalk.red,
CUSTOM: chalk.whiteBright
}

const LogLevels = {
WARN: "WARN",
INFO: "INFO",
CRITICAL: "CRITICAL",
SUCCESS: "SUCCESS",
FAILURE: "FAILURE"
FAILURE: "FAILURE",
CUSTOM: "CUSTOM"
}



export default class Logsmith {
constructor(options, statement) {
this.env = options.env || "default"
Expand Down Expand Up @@ -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)
})
}
}

}

0 comments on commit 1b82e97

Please sign in to comment.