Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 26
Registered: ‎06-24-2013
My Device: Z10
My Carrier: Verizon
Accepted Solution

Logging very long messages?

Hello, I'm trying to log out the contents of QVariantLists that I'm building from JSON web responses, however the console seems to truncate qDebugs at somewhere close to 500 characters, adding a "..." to the end. Is there a way to log the entire message? It's important to be able to see the data that I'm getting back from the web service.

 

Thank you!

 

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Logging very long messages?

It seems if they're longer than 511 characters (presumably 512 including a null terminator) then they're shortened to 508 plus the three dots and the null terminator.

It appears works at a low-level in the slog routines, so to work around that you'd have to do one of two things.

One is massage the data at the high level, before logging it, to chop it into bite-sized piece (<512 byte bites) and log them separately.

A second approach would be to redirect logging to your own mechanism, such as by writing to a file, where you wouldn't have such limits.

I can't see any reason to redirect all logging to a file, however, so if you can't chop these up easily, just write only these responses to a file and leave the rest of your logging alone.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 96
Registered: ‎06-05-2012
My Device: Developer
My Carrier: Developer

Re: Logging very long messages?

Hi,

 

You can use below code for write your response in file.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

QByteArray resArray(string_response.c_str());
QFile file(QDir::homePath() + "/"+fileName+".txt");
file.open(QIODevice::WriteOnly);
file.write(resArray);
file.flush();
file.close();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Thanks,

 

Developer
Posts: 16,986
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Logging very long messages?

strange, my logger service logs even very long webservice traces completely. that would be tad more than 511 characters, the most complex response i found were 212.000

i use standard qDebug with a custom message handler that adds some date stamps and outputs the whole via stdout and to a database.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Logging very long messages?

simon_hain, yes, qDebug to a custom message handler would work fine... this is a limitation of the in-memory slog facility. Seems built-in at a low level.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!