Skip to content

Commit

Permalink
Revert "Using loggerRunner for all Log Levels #39"
Browse files Browse the repository at this point in the history
This reverts commit 89def43.
  • Loading branch information
TanmoySG authored Jun 17, 2022
1 parent 66808f0 commit 93d60cd
Showing 1 changed file with 39 additions and 45 deletions.
84 changes: 39 additions & 45 deletions libraries/js/logsmith/logsmith.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as path from 'path';
import format from 'string-template';
import compile from 'string-template/compile.js';
import { loggerRunner } from './lib/drivers.js';
import * as path from 'path'
import { readConfigFile } from './lib/fetchConfigs.js';
import { LogFormats, LogLevels } from './lib/specs.js';
import { prepareJSONLog, consoleLogJSON, prepareStatementLog, consoleLogStatement } from './lib/logUtility.js';
import { ChalkLog, LogLevels, LogFormats } from './lib/specs.js';

const defaultLogStatementPattern = "[{level}] {body}"

Expand Down Expand Up @@ -31,64 +32,57 @@ export default class Logsmith {
}

INFO(log) {
loggerRunner(
LogLevels.INFO,
this.env,
this.compiledLogPattern,
this.logFormat,
log
)
if (this.logFormat == LogFormats.JSON) {
prepareJSONLog(LogLevels.INFO, log, this.env, function (LogJSON) {
consoleLogJSON(LogLevels.INFO, ChalkLog.INFO, LogJSON)
})
} else if (this.logFormat == LogFormats.STATEMENT) {
prepareStatementLog(LogLevels.INFO, log, this.env, this.compiledLogPattern, function (LogStatement) {
consoleLogStatement(LogLevels.INFO, ChalkLog.INFO, LogStatement)
})
}
}

WARN(log) {
loggerRunner(
LogLevels.WARN,
this.env,
this.compiledLogPattern,
this.logFormat,
log
)
if (this.logFormat == LogFormats.JSON) {
prepareJSONLog(LogLevels.WARN, log, this.env, function (LogJSON) {
consoleLogJSON(LogLevels.WARN, ChalkLog.WARN, LogJSON)
})
}
}


CRITICAL(log) {
loggerRunner(
LogLevels.CRITICAL,
this.env,
this.compiledLogPattern,
this.logFormat,
log
)
if (this.logFormat == LogFormats.JSON) {
prepareJSONLog(LogLevels.CRITICAL, log, this.env, function (LogJSON) {
consoleLogJSON(LogLevels.CRITICAL, ChalkLog.CRITICAL, LogJSON)
})
}
}

SUCCESS(log) {
loggerRunner(
LogLevels.SUCCESS,
this.env,
this.compiledLogPattern,
this.logFormat,
log
)
if (this.logFormat == LogFormats.JSON) {
prepareJSONLog(LogLevels.SUCCESS, log, this.env, function (LogJSON) {
consoleLogJSON(LogLevels.SUCCESS, ChalkLog.SUCCESS, LogJSON)
})
}
}

FAILURE(log) {
loggerRunner(
LogLevels.FAILURE,
this.env,
this.compiledLogPattern,
this.logFormat,
log
)
if (this.logFormat == LogFormats.JSON) {
prepareJSONLog(LogLevels.FAILURE, log, this.env, function (LogJSON) {
consoleLogJSON(LogLevels.FAILURE, ChalkLog.FAILURE, LogJSON)
})
}
}

LOG(loglevel, log) {
loglevel = loglevel.toUpperCase().substring(0, 8);
loggerRunner(
loglevel,
this.env,
this.compiledLogPattern,
this.logFormat,
log
)
if (this.logFormat == LogFormats.JSON) {
prepareJSONLog(loglevel, log, this.env, function (LogJSON) {
consoleLogJSON(loglevel, ChalkLog.CUSTOM, LogJSON)
})
}
}

}

0 comments on commit 93d60cd

Please sign in to comment.