A simple debugger for web sites using the browser's console. Based on the console wrapper from Paul Irish.
A demo page is provided so you can see the code in action.
The default state for the debugger is off. There are two ways to turn the debugger on.
debug.onproperty to *true*,
debug.on = true;. The default is *false*.
You use this debugger just as you would the normal browser
console.log() except you replace “console” with “debug”.
debug.log('This is a log message');
Just like with the normal console you can use string substitution
var animal = 'cow', count = 10; debug.log("The %s jumped over %d tall buildings", animal, count);
The above code will output to the console as “The cat jumped over 10 buildings”
All calls to the debug object will be saved in
debug.history which is an array of all the messages sent to the debug object.
var animal = 'dog', count = 1; debug.on = true; debug.log('The %s jumped over %d tall buildings', animal, count); debug.debug('example.html - line 10: There was a problem'); debug.warn('watch your step!'); debug.error('OMG, things are blowing up!'); /* debug.history outputs ['The %s jumped over %d tall buildings', animal, count] ... debug.history outputs ['OMG, things are blowing up!'] */
Here is a list of the current supported console message types:
log, info, warn, error, debug, dir, group, groupEnd
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.