[Qgis-developer] prints to std::cout in qgis
Mateusz Łoskot
mateusz at loskot.net
Wed Mar 22 11:59:32 EST 2006
Radim Blazek wrote:
> On 3/22/06, Mateusz Łoskot <mateusz at loskot.net> wrote:
>> nhugent at hispeed.ch wrote:
>>
>>> My suggestion is to not use std::cout for debug messages anymore,
>>> but rather the QgsDebug macro (which calls qDebug).
>>
>> I agree with Marco. I'd also suggest to provide a macro that can be
>> used to control debug messages per file (pair of .h/.cpp files).
>> The idea is to turn all debug messages off and leave turned on only
>> debug messages on for one particular file. This will help much to
>> filter/track only objects/operations we are interested in when
>> working on single feature/file. Now, QGIS debug mechanism outputs
>> huge amount of messages and many of them are useless in many cases,
>> so they should be filtered when not needed. This approach is used
>> in GEOS and it works well.
>>
>> There is a macro GEOS_DEBUG that is turned off by default. But if
>> someone want to debug/test e.g. Envelope class, then he has to put
>> one line into Envelope.cpp file:
>>
>> #define GEOS_DEBUG 1
>>
>> This solution could be improved to turn on/off all debug messages
>> globally or turn them on/off for particular file using local macro
>> (like the GEOS_DEBUG).
>
>
> That means that you have to recompile always when you need a debug
> message and that is clumsy.
Yes, you're right.
> I would prefere to control debug with enviroment variables. It can
> include also file specification. E.g. export QGIS_DEBUG=5 export
> QGIS_DEBUG_FILE=Envelope.cpp
OK, I can imagine how QGIS_DEBUG variable is used.
The value of QGIS_DEBUG controls significance of messages sent to output.
But how the second macro should work?
Do you expect that everytime and everywhere debug output API is used, it
reads for QGIS_DEBUG_FILE and checks if it contains current file.
If it does, then debug output is turned on for this file.
Right?
Basic example:
GEOS_DEBUG_PRINT("this is my debug message")
This macro is expanded to something like following operations:
Now, when QGIS is executed, macro checks:
- is there any QGIS_DEBUG_FILE deined?
- if there is, check if it contains file with name of current
file; here __FILE__ can be used
- if current file is there, print debug message, if not, just ignore it.
Is this your idea?
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
More information about the Qgis-developer
mailing list