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 committed Jun 17, 2022
1 parent 5da738a commit e1b0368
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 e1b0368

Please sign in to comment.