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
rakesh86shankar
Posts: 1,005
Registered: ‎05-22-2009
My Device: Not Specified

How to get the Debug Messages in Console

Hi,

 

I am trying to get the Debug messages in the Console,I tried Like

 

qDebug()<<"Demo App>>>>>>>>>>>>>>>>" ;

 

 

and in console I am searched for the output as given below

 

IssueConsole.jpg

 

Whether it Works because I came across the KB article 

 

http://supportforums.blackberry.com/t5/tkb/articleprintpage/tkb-id/Cascades%40tkb/article-id/16

 

 

What is present solution?

 

Thanks

Rakesh Shankar

 

Please use plain text.
Developer
javoid
Posts: 194
Registered: ‎11-24-2012
My Device: Dev Alpha B, Bold 9700

Re: How to get the Debug Messages in Console

I use:

std::cout << "some text << std::endl;

 If you do this, don't forget to

#include <iostream>

 

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: How to get the Debug Messages in Console

Please use plain text.
Contributor
chriske86
Posts: 43
Registered: ‎01-05-2013
My Device: Dev Alpha

Re: How to get the Debug Messages in Console

Hi,

 

qDebug() can't reach the console window of Momentics IDE by own. You must create a message handler, who will transfer qDebug() messages to the console. The easiest way is, to copy this method to your main.cpp file:

 

void myMessageOutput(QtMsgType type, const char *msg)
 {
     //in this function, you can write the message to any stream!
     switch (type) {
     case QtDebugMsg:
         fprintf(stderr, "Debug: %s\n", msg);
         break;
     case QtWarningMsg:
         fprintf(stderr, "Warning: %s\n", msg);
         break;
     case QtCriticalMsg:
         fprintf(stderr, "Critical: %s\n", msg);
         break;
     case QtFatalMsg:
         fprintf(stderr, "Fatal: %s\n", msg);
         abort();
     }
 }

 This will be the debug message handler. One thing is left: you must install this message handler for your application. Copy to the main() method this line of code right after the translator initialization:

 

qInstallMsgHandler(myMessageOutput);

 

cheers,

chriske

--------------------------------------------------------------
If my post was helpful or it was the solution for Your problem, please don't forget to give me a like, and mark my post as a solution. Thanks!
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: How to get the Debug Messages in Console

Please do not ship final apps with this stdour/stderr logging enabled.  It causes a performance hit because stdout/stderr are written to the flash disk while apps are running.

 

Consider only calling qInstallMsgHandler() in an #ifdef DEBIG condition or similar.

 

Cheers,

Sean

Please use plain text.
Developer
javoid
Posts: 194
Registered: ‎11-24-2012
My Device: Dev Alpha B, Bold 9700

Re: How to get the Debug Messages in Console

[ Edited ]

I have a check to avoid executing the statements, but you're right, I should have mentioned that

Please use plain text.