UNPKG

@teradataprebuilt/januspreview

Version:
79 lines 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TeradataLogging = void 0; const { v4: uuidv4 } = require("uuid"); BigInt.prototype.toJSON = function () { return this.toString(); }; Date.prototype.timestampNow = function () { return (this.getFullYear() + "-" + (this.getMonth() + 1 < 10 ? "0" : "") + (this.getMonth() + 1) + "-" + (this.getDate() < 10 ? "0" : "") + this.getDate() + "." + (this.getHours() < 10 ? "0" : "") + this.getHours() + ":" + (this.getMinutes() < 10 ? "0" : "") + this.getMinutes() + ":" + (this.getSeconds() < 10 ? "0" : "") + this.getSeconds() + "." + (this.getMilliseconds() < 100 ? "0" : "") + (this.getMilliseconds() < 10 ? "0" : "") + this.getMilliseconds()); }; class TeradataLogging { constructor(logLevel = 0) { this.bTracelog = false; this.bDebuglog = false; this.bTiminglog = false; this.id = ""; this.bTracelog = (logLevel & 1) !== 0; this.bDebuglog = (logLevel & 2) !== 0; this.bTiminglog = (logLevel & 8) !== 0; this.id = uuidv4().slice(24); } get bTraceLog() { return this.bTracelog; } get bDebugLog() { return this.bDebuglog; } get bTimingLog() { return this.bTiminglog; } traceLog(message, jsonStringify) { if (this.bTracelog) { if (jsonStringify) { message = JSON.stringify(message); } this.logMsg("TRACE", message); } } debugLog(message, jsonStringify) { if (this.bDebuglog) { if (jsonStringify) { message = JSON.stringify(message); } this.logMsg("DEBUG", message); } } timingLog(message, jsonStringify) { if (this.bTiminglog) { if (jsonStringify) { message = JSON.stringify(message); } this.logMsg("TIMING", message); } } logMsg(sCategory, msg) { console.log(new Date().timestampNow() + " [" + this.id + "] " + "NODEJS-" + sCategory + " " + msg); } } exports.TeradataLogging = TeradataLogging; //# sourceMappingURL=teradata-logging.js.map