Re: Newbie question on adding trace statements
Posted by Luigi Ballabio on Jan 03, 2005; 9:11am
URL: http://quantlib.414.s1.nabble.com/Newbie-question-on-adding-trace-statements-tp3463p3464.html
On 12/29/04 09:46:55, Joseph Wang wrote:
> I'd like to add some code into Quantlib to dump out intermediate results
> for debugging, and it seems that it would be a good thing to have some
> mechanism that you can turn on trace statements in response to an
> environment variable. Something similar to the
> Java Logger facility.
>
> What is the preferred way of doing this in Quantlib?
Joseph,
there's no such mechanism at the time, but I'd happily insert it. I
wouldn't go for a full-featured logging facility, though---I'd be happy
with something as simple as
QL_TRACE("x = " << x << ", y = " << y);
whose effects would be turned on/off by something like
Settings::instance().enableTracing(); // or disableTracing()
and whose destination would be set by something like
Settings::instance().traceTo(std::cerr); // or an ofstream, or whatever
Do you think this would fit the bill?
Later,
Luigi