Skip to content

Instantly share code, notes, and snippets.

@sjungling
Last active December 11, 2015 05:08
Show Gist options
  • Select an option

  • Save sjungling/4549846 to your computer and use it in GitHub Desktop.

Select an option

Save sjungling/4549846 to your computer and use it in GitHub Desktop.
# Replace YOUR_ORG with your global namespace
window.YOUR_ORG =
debug: false
log: (msg, type, context) ->
message = undefined
if window.console and @debug
if typeof msg is "string" and context isnt undefined
message = "(" + (new Date().getTime()) + ") " + context + ": " + msg
else
message = msg
if type is "error"
console.error message
else if type is "warn"
console.warn message
else
console.log message
/* Replace YOUR_ORG with your global namespace */
window.YOUR_ORG = {
debug: false,
log: function(msg, type, context) {
var message;
message = void 0;
if (window.console && this.debug) {
if (typeof msg === "string" && context !== void 0) {
message = "(" + (new Date().getTime()) + ") " + context + ": " + msg;
} else {
message = msg;
}
if (type === "error") {
return console.error(message);
} else if (type === "warn") {
return console.warn(message);
} else {
return console.log(message);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment