Skip to content

Instantly share code, notes, and snippets.

@w35l3y
Created August 2, 2019 15:31
Show Gist options
  • Save w35l3y/1d4e5578f7ce9d2a3d434729585defa6 to your computer and use it in GitHub Desktop.
Save w35l3y/1d4e5578f7ce9d2a3d434729585defa6 to your computer and use it in GitHub Desktop.
Estrutura genérica para tratamento de log
// depends on https://gist.github.com/w35l3y/07442c6adf297703ac7915526a980134
function Logger (script) {
var debug = script.debug;
this.debug = function () {
if (debug) {
console.debug.apply(null, arguments);
alert(Array.prototype.slice.apply(arguments).join("\n\n"));
}
};
this.info = function () {
debug && console.log.apply(null, arguments);
};
this.warn = function () {
console.warn.apply(null, arguments);
debug && alert(Array.prototype.slice.apply(arguments).join("\n\n"));
};
this.error = function () {
console.error.apply(null, arguments);
alert(Array.prototype.slice.apply(arguments).join("\n\n"));
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment