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
Posts: 89
Registered: ‎03-17-2013
My Device: Dev Alpha + Z10
My Carrier: I carry it myself.

filter console output

 

I get a lot of rubbish in console when my app is running:

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: Interlace handling should be turned on when using png_read_image
pushPage : mNavigationStack : ("18") 
NavigationPane: NavigationPaneOnFwdTransitionDone: emitting push transition ended for page: 18 client top: 18 
PpsTimeSettingsObject::newSettingsData() emitted 
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

 I'd like to get just qDebug() and console.log() messages. Is it possible?

 

I have found some posts implying that it isn't, but they might be outdated.


SQL Terminal – command-line interface to local SQLite database
Developer
Posts: 1,065
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: filter console output

[ Edited ]

Yes and no. You can write your own message handler for qDebug() but I believe anything sent to the console goes to the console regardless of what you do. You can try doing something like this in main.cpp:

 

#include <iostream>

namespace std
{
    extern ostream cerr;
} // namespace std

void myMessageOutput( QtMsgType type, const char *msg ) {
    switch ( type ) {
        case QtDebugMsg:
            std::cerr << "DEBUG: " << msg << "\n";
            break;
        case QtWarningMsg:
            std::cerr << "WARNING: " << msg << "\n";
            break;
        case QtCriticalMsg:
            std::cerr << "CRITICAL: " << msg << "\n";
            break;
        case QtFatalMsg:
            std::cerr << "FATAL: " << msg << "\n";
            abort();
            break;
    }
}

Q_DECL_EXPORT int main( int argc, char **argv ) {
    qInstallMsgHandler( myMessageOutput );

// ---The rest of your app startup code }

This will give you control of what happens to stuff sent to qDebug(), qWarning(), and qCritical() and qFatal(). You could alter this code to filter out anything you aren't interested in. I find that debug output gets cluttered quickly since many Cascades classes spit out warnings (not just qDebug() messages) for every trivial little action, such as popping a page from a NavigationPane.

 

Note that Momentics 10.2 finally got around to routing qDebug() to the console automatically, without needing this code to make that work, but if you use this code anyway, I recommend you turn the new feature off if you are using Momentics 10.2.

 

    "Preferences->BlackBerry->Device Log->Inject qDebug() and console.log messages into standard console"


ondrejandrej wrote:

 

I get a lot of rubbish in console when my app is running:

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: Interlace handling should be turned on when using png_read_image
pushPage : mNavigationStack : ("18") 
NavigationPane: NavigationPaneOnFwdTransitionDone: emitting push transition ended for page: 18 client top: 18 
PpsTimeSettingsObject::newSettingsData() emitted 
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

 I'd like to get just qDebug() and console.log() messages. Is it possible?

 

I have found some posts implying that it isn't, but they might be outdated.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: filter console output

If you are feeling adventurous, you can SSH into the device from Mometics, and then pipe the output slog2info -w into grep and filter for what you want.

 

So, if you did something like prepending you important deug messages with "+++++++", you could use the following command:

 

slog2info -w | grep "+++++++"

 and then you would just see messages that you have logged with a line similar to this:

 

qDebug() << "+++++++ " << "This is important for real: " << some_message << endl;

 

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 1,065
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: filter console output

Actually what I do is similar, but without SSH. I preface all the messages my app sends to qDebug(), qWarning() or qCritical() with "#####", then filter for that in the myMessageFunction() handler. I also installed a new ANSI console in Momentics (eclipse) that allows escape sequences to alter text colour, so I can colour code the messages I'm interested differently than others. The default Momentics console does colour escape sequences too, but I don't know what the codes are.

 


PBernhardt wrote:

If you are feeling adventurous, you can SSH into the device from Mometics, and then pipe the output slog2info -w into grep and filter for what you want.

 

So, if you did something like prepending you important deug messages with "+++++++", you could use the following command:

 

slog2info -w | grep "+++++++"

 and then you would just see messages that you have logged with a line similar to this:

 

qDebug() << "+++++++ " << "This is important for real: " << some_message << endl;

 






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: filter console output

The main advantage of using SSH is you can change what you are filtering on the fly, but yes, your approach is also exellent, especially if you use some nice colours.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Highlighted
Developer
Posts: 89
Registered: ‎03-17-2013
My Device: Dev Alpha + Z10
My Carrier: I carry it myself.

Re: filter console output


greenmr wrote:

Yes and no. You can write your own message handler for qDebug() but I believe anything sent to the console goes to the console regardless of what you do. You can try doing something like this in main.cpp:

 

#include <iostream>

namespace std
{
    extern ostream cerr;
} // namespace std

void myMessageOutput( QtMsgType type, const char *msg ) {
    switch ( type ) {
        case QtDebugMsg:
            std::cerr << "DEBUG: " << msg << "\n";
            break;
        case QtWarningMsg:
            std::cerr << "WARNING: " << msg << "\n";
            break;
        case QtCriticalMsg:
            std::cerr << "CRITICAL: " << msg << "\n";
            break;
        case QtFatalMsg:
            std::cerr << "FATAL: " << msg << "\n";
            abort();
            break;
    }
}

Q_DECL_EXPORT int main( int argc, char **argv ) {
    qInstallMsgHandler( myMessageOutput );

// ---The rest of your app startup code }

This will give you control of what happens to stuff sent to qDebug(), qWarning(), and qCritical() and qFatal(). You could alter this code to filter out anything you aren't interested in.


I added your code and installed the Eclipse plugin. Now I'm able to use colors. However I'm not able to filter content. Even if I remove all the lines starting with "std::cerr <<", I still get the same content printed to console. I have turned off qDebug message injection in IDE and I guess I get a bit less text, but it still contains messages starting with "libpng warning:" or "QNXWebViewProvider::scrollPositionChanged()"


SQL Terminal – command-line interface to local SQLite database