This plugin helps managing debugging in javascript. It looks for a url param or cookie and prints conditional to the browser console. it is useful if you want to log debug informations to the browser console on development hosts per default, but not in production. You can enable the debug mode in production via a url parameter.
bower install jquery.debug
$.debug(true);
$.debug.log('msg'); //prints to console
$.debug(false);
$.debug.log('msg'); //doesnt print to console
//sets 192.123.* hosts as development hosts
$.debug({developmentHosts: ['192.123.']})
It also exposes the class JQueryDebug
for manual instantiating.
$.debug true
$.debug.log 'msg' #prints to console
$.debug false
$.debug.log 'msg' #doesnt print to console
#adds 192.123.* hosts to development hosts
$.debug developmentHosts: [ '192.123.' ]
It also exposes the class JQueryDebug
for manual instantiating and extending.
List of hosts or host-substrings for development host detection. Default is:
- 127.0
- 192.168
- localhost
Name of the url param to watch for, default is 'debug'. You van use:
- ?debug=0
- ?debug=false
- ?debug=1
- ?debug=true
Name of the cookie for debug storing, default is 'debug'.
Initialize the plugin.
- with a configuration object.
- or sets the debug mode if one of
['1', 1, 'true', true, '0', 0, 'false', false]
is given. - If no parameter is given it returns the actual debug mode.
Updates the configuration.
Enables debug mode.
Disables debug mode.
Returns the actual debug mode.
Set the debug mode and stores it in the cookie. Valid values are:
- 0
- '0'
- false
- 'false'
- 1
- '1'
- true
- 'true'
Tells if the actual host is a development host.
Tells if the actual host is a production host.
Logs a massage to the browser console if in debug mode.
Logs a debug massage to the browser console if in debug mode.
Logs a error massage to the browser console if in debug mode.
Logs a info massage to the browser console if in debug mode.
Logs a warning massage to the browser console if in debug mode.
Alerts a massage if in debug mode.
- https://github.com/creative-workflow/jquery.debug
- https://travis-ci.org/creative-workflow/jquery.debug
- https://codeclimate.com/github/creative-workflow/jquery.debug
- http://bower.io/search/?q=jquery.debug
Check out the Contributing Guidelines