[Qgis-developer] prints to std::cout in qgis

Radim Blazek radim.blazek at gmail.com
Thu Mar 23 02:56:46 EST 2006


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



More information about the Qgis-developer mailing list