Reputation: 22375
In ruby there is a method on the Kernel object called set_trace_function. It will execute a given proc object on occasion, when a method is called or returns, or when an exception is raised. You can use this to make your own loggers and learn interesting things about your program &c...
Is there a similar facility in C++ or maybe in boost? Also, what is this facility called in general?
Thanks!
z.
Upvotes: 0
Views: 98
Reputation: 34308
Like Seth said this sort of stuff isn't directly available by the language. In order to do something similar in C++ you have to inject this sort of "monitoring code" into your own code during compilation.
In C or C++ this is often referred to as instrumentation or profiling.
To learn more I suggest you google it.
If what you are looking for instead is a logging or debugging helper framework, then you might want to read this (which is actually the second answer when you google instrumentation):
Instrumentation (diagnostic) library for C++
Upvotes: 1