Skip to content

Instantly share code, notes, and snippets.

@davetayls
Created October 31, 2011 11:13
Show Gist options
  • Save davetayls/1327298 to your computer and use it in GitHub Desktop.
Save davetayls/1327298 to your computer and use it in GitHub Desktop.
Basic debug module
/**
* Basic debug AMD module
* usage: debug.log('inside coolFunc',this,arguments);
*/
/*jslint browser: true, vars: true, white: true, forin: true */
/*global define, require */
(function(){
'use strict';
var debug = {
history: [],
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
log: function () {
this.history.push(arguments);
if (window.console) {
window.console.log(Array.prototype.slice.call(arguments));
}
},
error: function () {
this.history.push(arguments);
if (window.console) {
window.console.error(Array.prototype.slice.call(arguments));
}
}
};
if (window.define && window.define.amd) {
define(function(){ return debug; });
} else {
window.debug = debug;
}
}());
@davetayls
Copy link
Author

davetayls commented Feb 17, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment