Skip to content

Instantly share code, notes, and snippets.

@litil
Created February 19, 2014 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litil/9101528 to your computer and use it in GitHub Desktop.
Save litil/9101528 to your computer and use it in GitHub Desktop.
This simple logging method works in all modern browsers
function log() {
try {
// tries to log the message using the most common method
console.log.apply(console, arguments);
} catch(e) {
// catches any failure in logging
try {
// tries to log the Opera way
opera.postError.apply(opera, arguments);
} catch(e) {
// uses alert if all else fails
alert(Array.prototype.join.call(arguments, " "));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment