Skip to content

Instantly share code, notes, and snippets.

@egonelbre
Last active August 29, 2015 14:16
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 egonelbre/c7117b98cea93dca3496 to your computer and use it in GitHub Desktop.
Save egonelbre/c7117b98cea93dca3496 to your computer and use it in GitHub Desktop.
Logger = {
ensure: function(context){
var self = this;
var prefix = '[' + context + '] ';
this[context] = function(){
var args = Array.prototype.slice.call(arguments);
args.unshift(prefix);
console.log.apply(console, args);
}
}
};
InvokeLogger = Context(function(log){
Logger = log;
Logger.info("test");
Logger.info("second");
}, {
Logger: {
info: function(message){
this.ensure("info");
this.info("[ROLE]", message);
}
}
});
InvokeLogger(Logger);
Logger.info("testing");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment