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

Tim Sutton tim at linfiniti.com
Mon Apr 3 11:22:12 EDT 2006


Hi Marco

I think it would be interesting to combine the logger functions with
the unit tests I am planning. So for example a unit test may achieve a
result but produce critical errors / warnings (Im assuming if its
fatal, the unit test would fail). With this in mind it would be
interesting to propoage __FILE__ and __LINE__ into the logs. I was
also wondering if a simple xml format (or delimited text for xml
haters) could be produced by the logger e.g.

xml:

<Message file="qgisapp.cpp" line="1232" severity="critical">
  QGIS has detected a wobble in the earths orbit
</Message>

or:

File               Line    Severity  Message
qgisapp.cpp   1232   Critical    QGIS has detected a wobble in the earths orbit
etc.

My idea is that we could then record stats across the test suite. e.g.
I run the test suite and  the stats tell give me  a global report:

File | Total Fatal  | Uniqe Fatal | Total Critical | Unique Critical 
| Total Warning | Unique Warning
---------------------------------------------------------------------------------------------------------------------------------------
qgisapp   10              6                    5                     
4                10                   10
---------------------------------------------------------------------------------------------------------------------------------------
all files     100            88                 66                   
22                 99                  22
---------------------------------------------------------------------------------------------------------------------------------------


This would be very useful way of measuring the growth or reduction of
problems encountered.


Regards

Tim


On 4/3/06, nhugent at hispeed.ch <nhugent at hispeed.ch> wrote:
> 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
> >
> >
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>


--
Tim Sutton

Visit http://qgis.org for a great Open Source GIS
Skype: timlinux
MSN: tim_bdworld at msn.com
Yahoo: tim_bdworld at yahoo.com
Jabber: timlinux
Irc: timlinux on #qgis at freenode.net



More information about the Qgis-developer mailing list