@backtest/framework
Version:
Backtesting trading strategies in TypeScript / JavaScript
46 lines • 1.31 kB
JavaScript
;
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogLevel = void 0;
exports.error = error;
exports.info = info;
exports.debug = debug;
exports.trace = trace;
var LogLevel;
(function (LogLevel) {
LogLevel[LogLevel["ERROR"] = 40] = "ERROR";
LogLevel[LogLevel["INFO"] = 30] = "INFO";
LogLevel[LogLevel["DEBUG"] = 20] = "DEBUG";
LogLevel[LogLevel["TRACE"] = 10] = "TRACE";
})(LogLevel || (exports.LogLevel = LogLevel = {}));
let currentLevel = LogLevel.ERROR;
try {
currentLevel = LogLevel[((_b = (_a = process.env) === null || _a === void 0 ? void 0 : _a.FRAMEWORK_LOG_LEVEL) === null || _b === void 0 ? void 0 : _b.toUpperCase()) || 'ERROR'];
}
catch (error) {
currentLevel = LogLevel.ERROR;
}
function error(...args) {
if (_shouldLog(LogLevel.ERROR)) {
console.log('ERROR:', ...args);
}
}
function info(...args) {
if (_shouldLog(LogLevel.INFO)) {
console.log('INFO:', ...args);
}
}
function debug(...args) {
if (_shouldLog(LogLevel.DEBUG)) {
console.log('DEBUG:', ...args);
}
}
function trace(...args) {
if (_shouldLog(LogLevel.TRACE)) {
console.log('TRACE:', ...args);
}
}
function _shouldLog(level) {
return level >= currentLevel;
}
//# sourceMappingURL=logger.js.map