[Development] RFC: [Logging] Add quote(), noquote() stream modifiers to QDebug

Sebastian Lehmann qt at leemes.de
Fri Feb 28 12:13:32 CET 2014


Hi,

I would really welcome this feature.

While we're at it, we should also add something like escape() and  
noeascape() to handle special chars. Especially the null char will  
truncate the whole line due to the way the internal buffer gets  
finally printed in the QDebug destructor, which annoys people wanting  
to debug-print binary data.

See also http://stackoverflow.com/q/10913155/592323, or test it yourself:

     qDebug() << QByteArray("abc\0def", 7);

which will print

     "abc

but with escaping enabled we could print it like

     "abc\0def"

Of course, this feature should be disabled per default for  
compatibility reasons, unless you say we don't have guarantees for the  
actual format of qDebug output (I mean, it's for debugging, isn't  
it?); in this case I'd even say that escaping should be enabled per  
default, leading to less confusion / frustration.

Regards

Sebastian



Quoting Koehne Kai <Kai.Koehne at digia.com>:

> Hi,
>
> While contemplating about how to best get rid of qPrintable I came   
> up with the following proposal:
>
> https://bugreports.qt-project.org/browse/QTBUG-37146
>
> This is Qt 5.4 material. Anyhow, I'm keen on getting comments :) Of   
> course about the API as such, but also whether it can be implemented  
>  in a BC compatible way.
>
> Regards
>
> Kai
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>





More information about the Development mailing list