Created
August 6, 2013 07:08
-
-
Save marcmartino/6162700 to your computer and use it in GitHub Desktop.
Functional Logger
This file contains hidden or 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
var logger = function (loggingMethod) { | |
return function (logStatement) { | |
loggingMethod(logStatement); | |
}; }; | |
log = logger(console.log); | |
log = logger(alert); | |
log = logger(function (str) { | |
$(“#warning”).append(str); | |
}); | |
log = logger(function (str) { | |
$.ajax({ | |
type: “POST”, | |
data: str, | |
url: ‘/ajax/log/create’ | |
}); }); | |
log(“User not logged in”); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment