Created
February 19, 2018 07:51
-
-
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
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 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