I have a class (called MyClass), that contains about 20 misc methods, and a logging method. I want to call the logging method each time any method in that class is called, so for now, my code looks like:
|
This works fine, but it's a bit painful to have to call log() in each method, and the risk is high that if someone adds a method in there, he will forget to call it.
Is there any way I could attach an event or something, so that whenever a method from that class is called, my log() function is called ?
Any idea appreciated
Thanks,
Thibaut
ThibautPosted Aug 27, 2010, 9:29 AM
As for HTTP handler, I'm running the application on windows, it's not a web application, so I'm not sure I can use that..
Manikavelu VelayuthamPosted Aug 27, 2010, 7:30 AM
OR
You can write a HTTP handler for this class. Whenever a method is invoked from this class, log function can be automatically called.
Mark this post as answered, if this post really helps you.