JK-Debug
A pithy debugging helper that can define middlewares to fit your dev flavor.
Installation
$ npm i jk-debug
Usage
To see how to use the helper, check the example.js
.
If you are interested in the middleware implementation, ref to js-middleware.
API
Env Util
debugDetector(isDebug) -> boolean
- Enable debugging mode via query string debug
or env variable DEBUG
.
Base Class
new DebugWrapper(options) -> debugInstance
- Create and return a debugInstance
.
Options Parameter Table:
Parameter | Type | Required? | Description |
---|
isDebug | boolean | optional | By default debugging is enabled |
middlewareObject | object | optional | Apply the middleware object to the current context |
Instance Methods
-
isDebugEnabled() -> boolean
- Determine the debug runtime env.
-
switchDebuggingMode(isDebug)
- Enable/Disable the debugging mode.
-
log(message, ...arg)
- Like console.log
, but flexible and composable.
-
error(messageOrOptions, ...arg)
- Ditto, but support for detailed options.
-
getTimingResults() -> ParsedTiming
- Monitor the performance of page load/render.
License
MIT