smartdebug/ts/index.ts

27 lines
600 B
TypeScript
Raw Normal View History

2017-09-18 13:19:18 +00:00
import * as plugins from './smartdebug.plugins'
2015-11-15 19:35:13 +00:00
2017-09-18 13:19:18 +00:00
export class SmartDebug {
2017-09-18 15:53:23 +00:00
debugLogFunction: any = null
2017-09-18 13:19:18 +00:00
private debugEnabled: boolean = false
/**
* enables debugging output
*/
2017-09-19 15:48:56 +00:00
enableDebugging (debugLogFunction = console.log) {
2017-09-18 13:19:18 +00:00
this.debugEnabled = true
2017-09-18 15:53:23 +00:00
this.debugLogFunction = debugLogFunction
2017-09-18 13:19:18 +00:00
}
/**
* logs a message based on the contraints of the SmartDebug instance
*/
log (logObject: any) {
2017-09-18 15:53:23 +00:00
if (this.debugEnabled && this.debugLogFunction) {
this.debugLogFunction(logObject)
} else if (this.debugEnabled) {
2017-09-18 13:19:18 +00:00
console.log(logObject)
2015-11-15 19:35:13 +00:00
}
2017-09-18 13:19:18 +00:00
}
2015-11-15 19:35:13 +00:00
2017-09-18 13:19:18 +00:00
}