This commit is contained in:
Philipp Kunz 2017-09-19 17:58:59 +02:00
parent 0248a23e7d
commit b65a94b86c
3 changed files with 6 additions and 19 deletions

6
dist/index.d.ts vendored
View File

@ -1,13 +1,9 @@
export declare class SmartDebug {
debugLogFunction: any;
private debugEnabled;
/**
* enables debugging output
*/
enableDebugging(debugLogFunction?: {
(message?: any, ...optionalParams: any[]): void;
(message?: any, ...optionalParams: any[]): void;
}): void;
enableDebugging(): void;
/**
* logs a message based on the contraints of the SmartDebug instance
*/

11
dist/index.js vendored
View File

@ -2,27 +2,22 @@
Object.defineProperty(exports, "__esModule", { value: true });
class SmartDebug {
constructor() {
this.debugLogFunction = null;
this.debugEnabled = false;
}
/**
* enables debugging output
*/
enableDebugging(debugLogFunction = console.log) {
enableDebugging() {
this.debugEnabled = true;
this.debugLogFunction = debugLogFunction;
}
/**
* logs a message based on the contraints of the SmartDebug instance
*/
log(logObject) {
if (this.debugEnabled && this.debugLogFunction) {
this.debugLogFunction(logObject);
}
else if (this.debugEnabled) {
if (this.debugEnabled) {
console.log(logObject);
}
}
}
exports.SmartDebug = SmartDebug;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBQUE7UUFDRSxxQkFBZ0IsR0FBUSxJQUFJLENBQUE7UUFDcEIsaUJBQVksR0FBWSxLQUFLLENBQUE7SUFxQnZDLENBQUM7SUFuQkM7O09BRUc7SUFDSCxlQUFlLENBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLEdBQUc7UUFDN0MsSUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLENBQUE7UUFDeEIsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGdCQUFnQixDQUFBO0lBQzFDLENBQUM7SUFFRDs7T0FFRztJQUNILEdBQUcsQ0FBRSxTQUFjO1FBQ2pCLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxZQUFZLElBQUksSUFBSSxDQUFDLGdCQUFnQixDQUFDLENBQUMsQ0FBQztZQUMvQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsU0FBUyxDQUFDLENBQUE7UUFDbEMsQ0FBQztRQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUM3QixPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ3hCLENBQUM7SUFDSCxDQUFDO0NBRUY7QUF2QkQsZ0NBdUJDIn0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBQUE7UUFDVSxpQkFBWSxHQUFZLEtBQUssQ0FBQTtJQWtCdkMsQ0FBQztJQWhCQzs7T0FFRztJQUNILGVBQWU7UUFDYixJQUFJLENBQUMsWUFBWSxHQUFHLElBQUksQ0FBQTtJQUMxQixDQUFDO0lBRUQ7O09BRUc7SUFDSCxHQUFHLENBQUUsU0FBYztRQUNqQixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUN0QixPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ3hCLENBQUM7SUFDSCxDQUFDO0NBRUY7QUFuQkQsZ0NBbUJDIn0=

View File

@ -1,24 +1,20 @@
import * as plugins from './smartdebug.plugins'
export class SmartDebug {
debugLogFunction: any = null
private debugEnabled: boolean = false
/**
* enables debugging output
*/
enableDebugging (debugLogFunction = console.log) {
enableDebugging () {
this.debugEnabled = true
this.debugLogFunction = debugLogFunction
}
/**
* logs a message based on the contraints of the SmartDebug instance
*/
log (logObject: any) {
if (this.debugEnabled && this.debugLogFunction) {
this.debugLogFunction(logObject)
} else if (this.debugEnabled) {
if (this.debugEnabled) {
console.log(logObject)
}
}