[Development] Proposal: Changing the default output of qDebug and friends

kai.koehne at nokia.com kai.koehne at nokia.com
Thu Mar 29 09:03:52 CEST 2012


> -----Original Message-----
> From: development-bounces+kai.koehne=nokia.com at qt-project.org
> [mailto:development-bounces+kai.koehne=nokia.com at qt-project.org] On
> Behalf Of Ramsay Lincoln (Nokia-MP/Brisbane)
> Sent: Thursday, March 29, 2012 1:42 AM
> To: development at qt-project.org
> Subject: Re: [Development] Proposal: Changing the default output of
> qDebug and friends
> 
> On 03/29/2012 12:39 AM, ext kai.koehne at nokia.com wrote:
> > PS: From an IDE perspective including the file + line would help so
> > that you could just 'jump' to the source of a warning by clicking on
> > it. However, the file string can get quite long (think about shadow
> > builds) ...

Hi Lincoln,

> Why can't Creator just set the QT_MESSAGE_PATTERN environment variable
> then and leave the default alone? Creator would not need to show the
> filename and line number, just use them for when you click on the warnings.

You're right, that's actually what I intend do for apps started from within Qt Creator, and which is why I don't suggest including %{file}, %{line} in the default pattern.

Anyhow: Is the current default of printing just the message really the optimal one ? It leads to anti-patterns like

  qDebug() << Q_FUNC_INFO << xxx;
  // note that QT_MESSAGE_PATTERN="%{function} %{message}" produces much nicer output

or

  qWarning() << "Warning: xxx";

It also leads to a misuse of using qDebug for 'normal' application output, e.g.

  // misuse of qDebug, will  look ugly with QT_MESSAGE_PATTERN, might break with future category logging
  if (app.arguments().size() != 2)
      qDebug() << "myapp <file>";

So IMO a bit more verbose output wouldn't harm, and actually help in keeping the code clean.

Regards

Kai

> --
> Lincoln Ramsay - Senior Software Engineer Qt Development Frameworks,
> Nokia - http://qt.nokia.com/
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list