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
Developer
raffi
Posts: 154
Registered: ‎06-23-2012
My Device: Z10 & Z30
Accepted Solution

Dealing with qDebug() in release candidate

As we all know, we have had to do some minor fancywork in order to be able to use qDebug and see our output in the console based on the advice here: https://developer.blackberry.com/cascades/download/releasenotes/#limitations

 

As we also know, using this method affects the performance of the app.

 

So, when it comes time to build for Release-Device, do we remove the myMessageOutput function and the qInstallMsgHandler call from main? Or will the #ifndef QT_NO_DEBUG clause make sure performance is not impacted?

Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Dealing with qDebug() in release candidate

qDebug() and qWarning() will work in Release build too. QT_NO_DEBUG doesn't affect them.

 

So to remove logging you'll need to define QT_NO_DEBUG_OUTPUT and QT_NO_WARNING_OUTPUT for the entire project. This will disable default logging function.

 

When using custom handler you're controlling how the output is printed so check for these macros explicitly if you're using your own logging function.

 

You might want to check this page for details:

http://qt-project.org/doc/qt-4.8/debug.html


Andrey Fidrya, @zmeyc on twitter
Developer
raffi
Posts: 154
Registered: ‎06-23-2012
My Device: Z10 & Z30

Re: Dealing with qDebug() in release candidate

Ah, okay. Well, I was only assuming that QT_NO_DEBUG would affect qDebug() because of this block of code in my main:

#ifndef QT_NO_DEBUG
qInstallMsgHandler(myMessageOutput);
#endif

It only attaches the message output function depending on QT_NO_DEBUG. Would I still have to define QT_NO_DEBUG_OUTPUT and QT_NO_WARNING_OUTPUT then?

If so, then how would I go about doing that? Some searching around tells me that I need to set it up in my .pro file like this:

DEFINES += QT_NO_WARNING_OUTPUT QT_NO_DEBUG_OUTPUT

But I'd obviously prefer to only have that there in the Release-Device configuration.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Dealing with qDebug() in release candidate

[ Edited ]

It only attaches the message output function depending on QT_NO_DEBUG. Would I still have to define QT_NO_DEBUG_OUTPUT and QT_NO_WARNING_OUTPUT then?

 

Yes, you'll need to disable the default ones.

 

But I'd obviously prefer to only have that there in the Release-Device configuration.

 

In Qt it can be done like this:

 

 

Release: DEFINES += QT_NO_WARNING_OUTPUT QT_NO_DEBUG_OUTPUT

Probably it will work for Cascades too.

Clean all before rebuilding and check the compilation logs to ensure they were applied.

 


Andrey Fidrya, @zmeyc on twitter
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: Dealing with qDebug() in release candidate

Try this in your .pro file

 

device {

CONFIG(release, debug|release) {

DEFINES += QT_NO_WARNING_OUTPUT QT_NO_DEBUG_OUTPUT

}

}

Like all of my posts
Developer
raffi
Posts: 154
Registered: ‎06-23-2012
My Device: Z10 & Z30

Re: Dealing with qDebug() in release candidate

[ Edited ]

Thanks guys, I'll get back to you about whether that worked or not. For now, I am unable to run my app when in Release mode... I have a thread about that if you think you can help out (second post): http://supportforums.blackberry.com/t5/Cascades-Development/Compiling-libraries-and-resources/td-p/2...

 

EDIT: Alright fixed the issue and now I've tested it and I see that nothing is being outputted. Looks to be perfect. I ran slog2info and saw absolutely nothing being outputted while in Release mode, while everything under the sun was being printed in Debug mode.

 

Thanks guys.

 

Oh, one more question: Does this mean it's safe to leave qDebug and console.logs in the code? Or is it still a good idea to comment those out anyway?

Developer
billbsb
Posts: 144
Registered: ‎03-25-2011
My Device: Playbook, Z10 L.E.

Re: Dealing with qDebug() in release candidate

Hi guys,

 

have you checked these already? They are kind of old but I guess they are still valuable.

 

http://qt-project.org/forums/viewthread/25512

 

http://qt-project.org/forums/viewthread/10427

 

Basically, there's no overhead of qDebug() function execution. The info is a bit old but I guess it's still valid. I use it on my apps and it works.

 

Cheers.

Cheers!
Developer
raffi
Posts: 154
Registered: ‎06-23-2012
My Device: Z10 & Z30

Re: Dealing with qDebug() in release candidate

Thanks for the links. Despite there possibly being no overhead of calling qDebug(), I think it's not a big deal to use the solution provided above, as it's simple enough to implement anyway.