Created
February 19, 2014 21:04
-
-
Save litil/9101528 to your computer and use it in GitHub Desktop.
This simple logging method works in all modern browsers
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
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