Skip to content

Instantly share code, notes, and snippets.

@davetayls
Created October 31, 2011 11:13
Show Gist options
  • Select an option

  • Save davetayls/1327298 to your computer and use it in GitHub Desktop.

Select an option

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;
}
}());
@ArnoldZokas

Copy link
Copy Markdown

A similar implementation is used in HTML5 Boilerplate. Have a look at https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js

@davetayls

davetayls commented Feb 17, 2012 via email

Copy link
Copy Markdown
Author

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