Created
August 25, 2017 06:46
-
-
Save RazorNd/fb17fc22fdf352c1c698134fdb1c44db to your computer and use it in GitHub Desktop.
This file contains 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
function loggerDecorator(object, methodName) { | |
const method = object[methodName]; | |
function loggerWrapper () { | |
console.log("Method: " + methodName + " call with params: ", Array.prototype.join.call(arguments, ', ')); | |
console.trace(); | |
method.apply(object, arguments); | |
} | |
loggerWrapper.oldMethod = method; | |
loggerWrapper.restoreOldMethod = function() { | |
object[methodName] = method; | |
} | |
object[methodName] = loggerWrapper; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment