I am trying to write a logger object which logs messages to screen. here is my code.
http://github.com/huseyinyilmaz/javascript-logger
in every function that needs to log something, I am writing loggerstart and loggerEnd functions at start and end of my functions. But I want to run thos codes automaticalls for every function. is there a way to modify Function prototype so every function call can run automatically.
(I am not using any javascript framework.)
I am trying to write a logger object which logs messages to screen. here
Share
EDIT: Rewritten the function to make it more modularWell, this is a creepy way to do it, but I use this way sometimes when I need overriding some functions. It works well, allows any kind of customization and easy to understand (still creepy).
However, you will need to have all your functions stored in some kind of global object. See the example for details.
And some usage example:
Output will be:
start,10,end,start,6,end,start,5,endSo generally it allows you to wrap each function in some object automatically with a custom written wrapper function.