Last active
December 16, 2015 06:29
-
-
Save zedd45/f045e9cf75231e7ccc44 to your computer and use it in GitHub Desktop.
intelligent log mechinism
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
/** | |
* inform the developers that there has been a problem by printing a message to the console | |
* @param consoleMessage [string] - a (developer friendly) description of the error | |
* @param errorObject [ Error object literal] - the Error object, usually generated by an exception | |
* @param consoleMethod [string] (optional) - the type of console message to use (eg - error, log, warn ). Defaults to 'log' | |
*/ | |
logMessage: function ( consoleMessage, errorObject, consoleMethod) { | |
// var IEMessage = errorObject && errorObject.description ? errorObject.description : 'No additonal details available'; | |
if ( "object" !== typeof console ) { return -1; } | |
if ( !consoleMethod ) { | |
consoleMethod = 'log'; | |
} | |
if ( "function" === typeof console[consoleMethod] ) { | |
// we can directly output the object for inspection in better browsers | |
console[consoleMethod]( consoleMessage, errorObject); | |
} else if ( "function" === typeof console.log ){ | |
console.log("a log was attempted, but we were unable to log it the specified way (" + consoleMethod + "). Message Sent: " + consoleMessage); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment