Created
March 10, 2016 02:27
-
-
Save jvanasco/a18eaec1d5714d468349 to your computer and use it in GitHub Desktop.
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
if (typeof console === 'undefined') { | |
window.console = { | |
log: function () {} | |
}; | |
} | |
function loggerFactory(label) { | |
return (function () { | |
var timestamp = function () {}; | |
timestamp.toString = function () { | |
var label_line = label; | |
// this just checks for a certain global var which is only | |
// set on a Porthole window. lets me test interplay of js loaded | |
// into an iframe | |
if (CiPortholeApiWorker && CiPortholeApiWorker.is_worker) { | |
label_line = 'WORKER][' + label; | |
} | |
var port = "[" + window.location.protocol + "]"; | |
return port + "[" + label_line + ' ' + (new Date()).toLocaleTimeString() + "]"; | |
}; | |
if (DEBUG) { return { log: console.log.bind(console, '%s', timestamp) }; } | |
return { log: function () {} }; | |
})(); | |
} | |
function loggerFactoryNull(label) { | |
return(function () { return { log: function () {} }; }()); | |
} | |
var lwDebug = loggerFactory('web.debug'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment