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
BrandonO
Posts: 16
Registered: ‎01-17-2013
My Device: None
My Carrier: None
Accepted Solution

Printing to console in QNX Momentics IDE?

How do I actually go about printing to the console from one of my cpp files?  All I'm trying to do is print some data so I can see what I'm working with and then move forward accordingly.

 

When working on Android apps in Eclipse, all I had to do was type System.out.println(); and fill it with any object or variable and it would spit it out.  I can't seem to find anything similar here.

 

Thanks in advance!

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Printing to console in QNX Momentics IDE?

qDebug() and similar forms of output should go to the "slog2" output for the app, which writes a special file into a RAM drive area where it can be monitored from Momentics using some View Log feature (you'll have to google or search the forum... I don't use it) or by connecting to the device with SSH and using "slog2info -w" or a similar form of that command.

Any output that doesn't get redirected there should end up in the logs/log output file, which is written to the actual flash filesystem and therefore a less desirable target than slog2, and you can also view that either through the IDE or via SSH, in this case just by using "cat" or possibly "tail -f logs/log" after changing the current directory to your app's sandbox folder.

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!
Please use plain text.
Contributor
BrandonO
Posts: 16
Registered: ‎01-17-2013
My Device: None
My Carrier: None

Re: Printing to console in QNX Momentics IDE?

Thanks. That got me on the right track to figuring out the issue. The attached link gives insturctions to enable qDebug()

https://developer.blackberry.com/cascades/download/releasenotes/#limitations
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Printing to console in QNX Momentics IDE?

Note that qDebug() should already be "enabled" by default now, but with the output going to the slog2 output as I mentioned. What you've found is a way to redirect it to the old logs/log output, in the actual flash filesystem. That works, but has disadvantages as noted earlier.

(Just noting that for others who will read this later.)

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!
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: Printing to console in QNX Momentics IDE?

Why not just use simple fprintf to stdout?




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Printing to console in QNX Momentics IDE?

The qDebug() function provides additional functionality that fprintf() doesn't provide, useful in C++ programs. There are many ways to get output though... if fprintf() works for you, by all means use it. I'd strongly suggest in a release version that you #ifdef those out, however, so that your app is not constantly writing to flash memory whenever it runs. That's why switching to slog2(), even in a C app, would be worth considering.

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!
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: Printing to console in QNX Momentics IDE?

Thank you. I have have a look of this logging feature. Do you know where to config qDebug to output to a log file or output to the console?




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Printing to console in QNX Momentics IDE?

Brandon already posted a link for that above.

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!
Please use plain text.