Created
October 31, 2011 11:13
-
-
Save davetayls/1327298 to your computer and use it in GitHub Desktop.
Basic debug module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} | |
}()); |
Author
davetayls
commented
Feb 17, 2012
via email
Yeah, this is based on that but is also an AMD module and includes the
error logger
…On 16 Feb 2012, at 23:29, Arnold Zokas ***@***.*** > wrote:
A similar implementation is used in HTML5 Boilerplate. Have a look
at https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1327298
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment