Skip to content

Instantly share code, notes, and snippets.

@pankajladhar
Created February 19, 2018 07:51
Show Gist options
  • Save pankajladhar/2f807bb6aacb6c7604bc9eca8b660710 to your computer and use it in GitHub Desktop.
Save pankajladhar/2f807bb6aacb6c7604bc9eca8b660710 to your computer and use it in GitHub Desktop.
This code snippet will default console.log. It will print method name with message
var console=(function(oldCons){
return {
log: function(){
oldCons.log('%c' + "[ " + arguments.callee.caller.name + " method ]", 'background: #222; color: #bada55', arguments[0]);
}
};
}(window.console));
window.console = console;
var hello = function() {
console.log("Hello Pankaj")
}
var hi = function() {
console.log("hi Pankaj")
}
var usingObject = {
objectMethod : function(){
console.log("objectMethod");
}
}
var factory = function() {
return {
factoryMethod : function(){
console.log("factoryMethod");
}
}
}
hello();
hi();
usingObject.objectMethod();
factory().factoryMethod();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment