44 lines
2.1 KiB
JavaScript
44 lines
2.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
class SmartDebug {
|
|
constructor(debugTopic) {
|
|
this._debugEnabled = false;
|
|
if (process.env.SMARTDEBUG === 'true' ||
|
|
(debugTopic && process.env.SMARTDEBUG_TOPIC === debugTopic)) {
|
|
this.enableDebugging();
|
|
}
|
|
}
|
|
get debugEnabled() {
|
|
return this._debugEnabled;
|
|
}
|
|
/**
|
|
* enables debugging output
|
|
*/
|
|
enableDebugging() {
|
|
console.log('Enabled Debugging!');
|
|
this._debugEnabled = true;
|
|
}
|
|
/**
|
|
* disables debugging
|
|
*/
|
|
disableDebugging() {
|
|
this._debugEnabled = false;
|
|
}
|
|
/**
|
|
* logs a message based on the contraints of the SmartDebug instance
|
|
*/
|
|
log(logObject) {
|
|
if (this._debugEnabled) {
|
|
// tslint:disable-next-line:no-console
|
|
console.log(logObject);
|
|
}
|
|
}
|
|
/**
|
|
* a function returning
|
|
*/
|
|
isDebugMode() {
|
|
return this._debugEnabled;
|
|
}
|
|
}
|
|
exports.SmartDebug = SmartDebug;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBR0UsWUFBWSxVQUFtQjtRQUZ2QixrQkFBYSxHQUFZLEtBQUssQ0FBQztRQUdyQyxJQUNFLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVSxLQUFLLE1BQU07WUFDakMsQ0FBQyxVQUFVLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsS0FBSyxVQUFVLENBQUMsRUFDM0Q7WUFDQSxJQUFJLENBQUMsZUFBZSxFQUFFLENBQUM7U0FDeEI7SUFDSCxDQUFDO0lBRUQsSUFBSSxZQU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