Skip to content

Instantly share code, notes, and snippets.

@antila
antila / debugLog.js
Created January 31, 2013 10:40
Debug log helper. Never add a console.log to your code. This one also runs a stack trace to show where it got called from. Otherwise you'll just see the line in this gist as the source of the log message, and that isn't helpful since you want to see where the log call was made.
var app = {
debug: function(message, level) {
// Default level for logs
if (typeof level === 'undefined' || level === 'log') {
level = 'info';
}
// If we have a console...
if (typeof console === 'object' && typeof console.debug === 'function') {
// ...and the requested log level exists