[Qgis-developer] prints to std::cout in qgis
nhugent at hispeed.ch
nhugent at hispeed.ch
Mon Apr 3 10:39:10 EDT 2006
Hi qgissers,
I will have time to do the implementation of the logger class tomorrow. My suggestion is a header as below. QgsLogger would query the environment variables QGIS_DEBUG and (if set) QGIS_DEBUG_FILE and print out messages or not.
The question is how the output should be controled by QGIS_DEBUG. One possibility would be to have QGIS_DEBUG=1 for fatal, QGIS_DEBUG=2 for fatal and critical, QGIS_DEBUG=3 for fatal, critical, warning, etc. If QGIS_DEBUG_FILE is set, only messages from that file will be printed. Else, messages from all files will be printed. What do you think?
class QgsLogger
{
public:
static debug(QString msg, const char* file = 0, const char* function = 0);
static debug(QString var, int val, const char* file = 0, const char* function = 0);
static debug(QString var, double val, const char* file = 0, const char* function = 0); //goes to qDebug
static warning(QString msg); //goes to qWarning
static critical(QString msg); //goes to qCritical
static fatal(QString msg); //goes to qFatal
}
Marco
>On 3/22/06, Tim Sutton <tim at linfiniti.com> wrote:
>> One other idea I could throw into the pot is to have a logger class. We
>> could then set it up to write to console, to file or even in the future
>> to some part of the gui. The latter could help when we have non
>> technical users and windows users who experience problems - we can just
>> ask us to send output from the logger window or whathaveyou. Log
>> requests could be static methods or we could use qt signals and slots
>> and connect the logger to objects being logged when they are
>> instantiated. Example invocation mechanisms:
>>
>> emit logMessage("foo",QgsLogger::Critical);
>> emit logMessage("foo",QgsLogger::Informational);
>>
>> or
>>
>> QgsLogger::logMessage("foo",QgsLogger::Critical);
>> QgsLogger::logMessage("foo",QgsLogger::Informational);
>
>I prefer the second over emit. But it is too long, I would make it shorter:
>
>QgsLog::critical("foo");
>QgsLog::info("foo");
>QgsLog::debug(1,"foo"); // 1 is level controled by env. var.
>
>It is also often useful to print variable name - value pairs and
>QString::number() is too long, so I would suggest also
>
>QgsLog::debug(int l, QString var, int val);
>QgsLog::debug(int l, QString var, double val);
>
>Radim
>
>> Just another thought anyway...
>>
>> Regards
>>
>> Tim
>_______________________________________________
>Qgis-developer mailing list
>Qgis-developer at lists.qgis.org
>http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>
>
More information about the Qgis-developer
mailing list