Re: Newbie question on adding trace statements
Posted by
Joseph Wang on
Jan 03, 2005; 7:57pm
URL: http://quantlib.414.s1.nabble.com/Newbie-question-on-adding-trace-statements-tp3463p3465.html
There should probably be the concept of different debug levels, so that
you can set things up for minimal trace or dump every single number.
The interface should probably look like
QL_TRACE(int tracelevel, output);
Settings::instance.setTraceLevel(int);
The trace levels that java Logger uses should be plenty.
Luigi Ballabio wrote:
> 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
>