Skip to content

Instantly share code, notes, and snippets.

@marcmartino
Created August 6, 2013 07:08
Show Gist options
  • Save marcmartino/6162700 to your computer and use it in GitHub Desktop.
Save marcmartino/6162700 to your computer and use it in GitHub Desktop.
Functional Logger
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