From 4dea1cfac26d6b8ca66b0e41ef3b88e1a833b22b Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 18 Sep 2017 17:53:23 +0200 Subject: [PATCH] now accepts third party debug function --- dist/index.d.ts | 3 ++- dist/index.js | 11 ++++++++--- ts/index.ts | 8 ++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index d8782ee..18c9805 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,9 +1,10 @@ export declare class SmartDebug { + debugLogFunction: any; private debugEnabled; /** * enables debugging output */ - enableDebugging(): void; + enableDebugging(debugLogFunction?: any): void; /** * logs a message based on the contraints of the SmartDebug instance */ diff --git a/dist/index.js b/dist/index.js index 2f60464..cfbe799 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2,22 +2,27 @@ Object.defineProperty(exports, "__esModule", { value: true }); class SmartDebug { constructor() { + this.debugLogFunction = null; this.debugEnabled = false; } /** * enables debugging output */ - enableDebugging() { + enableDebugging(debugLogFunction = null) { this.debugEnabled = true; + this.debugLogFunction = debugLogFunction; } /** * logs a message based on the contraints of the SmartDebug instance */ log(logObject) { - if (this.debugEnabled) { + if (this.debugEnabled && this.debugLogFunction) { + this.debugLogFunction(logObject); + } + else if (this.debugEnabled) { console.log(logObject); } } } exports.SmartDebug = SmartDebug; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBQUE7UUFDVSxpQkFBWSxHQUFZLEtBQUssQ0FBQTtJQWtCdkMsQ0FBQztJQWhCQzs7T0FFRztJQUNILGVBQWU7UUFDYixJQUFJLENBQUMsWUFBWSxHQUFHLElBQUksQ0FBQTtJQUMxQixDQUFDO0lBRUQ7O09BRUc7SUFDSCxHQUFHLENBQUUsU0FBYztRQUNqQixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUN0QixPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ3hCLENBQUM7SUFDSCxDQUFDO0NBRUY7QUFuQkQsZ0NBbUJDIn0= \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBQUE7UUFDRSxxQkFBZ0IsR0FBUSxJQUFJLENBQUE7UUFDcEIsaUJBQVksR0FBWSxLQUFLLENBQUE7SUFxQnZDLENBQUM7SUFuQkM7O09BRUc7SUFDSCxlQUFlLENBQUUsZ0JBQWdCLEdBQUcsSUFBSTtRQUN0QyxJQUFJLENBQUMsWUFBWSxHQUFHLElBQUksQ0FBQTtRQUN4QixJQUFJLENBQUMsZ0JBQWdCLEdBQUcsZ0JBQWdCLENBQUE7SUFDMUMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsR0FBRyxDQUFFLFNBQWM7UUFDakIsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFlBQVksSUFBSSxJQUFJLENBQUMsZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO1lBQy9DLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsQ0FBQTtRQUNsQyxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDO1lBQzdCLE9BQU8sQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUE7UUFDeEIsQ0FBQztJQUNILENBQUM7Q0FFRjtBQXZCRCxnQ0F1QkMifQ== \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index 46703b7..e31db1a 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,20 +1,24 @@ import * as plugins from './smartdebug.plugins' export class SmartDebug { + debugLogFunction: any = null private debugEnabled: boolean = false /** * enables debugging output */ - enableDebugging () { + enableDebugging (debugLogFunction = null) { this.debugEnabled = true + this.debugLogFunction = debugLogFunction } /** * logs a message based on the contraints of the SmartDebug instance */ log (logObject: any) { - if (this.debugEnabled) { + if (this.debugEnabled && this.debugLogFunction) { + this.debugLogFunction(logObject) + } else if (this.debugEnabled) { console.log(logObject) } }