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: 95
Registered: ‎02-23-2011
My Device: Z10 STL100-1
My Carrier: IM3

Console.log doesn't work

Inb4 people say "Known Limitations", I've consulted these threads:

 

http://supportforums.blackberry.com/t5/Cascades-Development/console-debug-and-qDebug-not-printing-in...

 

http://supportforums.blackberry.com/t5/Cascades-Development/Unresolved-symbol-errors-when-attempting...

 

I've launched SSH session, and I can confirm that slog2info -w results in real-time logging as I trigger touch events, meaning I'm connected to the right target (of which there is only one anyway) and the connection is live. I laucnhed via "Debug", not "Run".

 

I have this JavaScript function:

 

function getBatteryLevel(){
return _battery.level + "%";
 }

 

This JavaScript function is tied to a label, which fills its text property with that function:

Label{

text: getBatteryLevel()

}

 

The codes don't reflect the actual code (especially the parent hierachy), but they work as expected, the label has the value returned by the JavaScript function

 

The value automatically updates in real-time, raising my concern of it updating due to rapidly executibng every second, wasting resources, so I asked about it here:

 

http://supportforums.blackberry.com/t5/Cascades-Development/Does-this-code-consume-performance-too-m...

 

It looks like the code updates itself via signals, meaning it's as optimized as it can be. To test it, I put console.log() to said JavaScript function to make this:

 

function getBatteryLevel(){
console.log("RaestlozDebugTextIdentifier")
return _battery.level + "%";
}

 

Note the highly unique text, which is bound to be recognizable. The problem is, I cannot find that text anywhere, so I'm a bit confused. At the very least, the function should've been called once, but I can't find that text in the slogger2.log

 

Can someone tell me what's going on?

BlackBerry Z10
Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: Console.log doesn't work

Try these options with the slog2info command...

 

slog2info -w | grep Debug

 

Developer
Posts: 95
Registered: ‎02-23-2011
My Device: Z10 STL100-1
My Carrier: IM3

Re: Console.log doesn't work

[ Edited ]

Nope, still nothing. tried to type it twice, nothing...

 

is there a... more reliable way of printing stuff into console? 

 

EDIT:

I mean, the highly unique identifier is still not found. Wonder how it could happen?

BlackBerry Z10
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Console.log doesn't work

Hi,

Didn't you by any chance redirect application's debug output to stdout using qInstallMsgHandler? It won't appear in slogger2 output then.

Try creating a button and adding console.log() to it's onClicked handler, so you can control the exact time when the log command is called.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 95
Registered: ‎02-23-2011
My Device: Z10 STL100-1
My Carrier: IM3

Re: Console.log doesn't work

I didn't do anything, everything about the debugging is left at default settings.

This is the first time I've heard about "qInstallMsgHandler", to be honest.

I'll do that. It's a bit late here so I'll do it tomorrow.

By the way, is there a way to reliably output stuff into console instead of slogger2 log?

Performance hit is acceptable, this is just to debug anyway
BlackBerry Z10
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Console.log doesn't work

Redirecting the logs is described in "Known Limitations" section of this page:

https://developer.blackberry.com/cascades/download/releasenotes/

 

 

console.log() works reliably for me. Well, it stopped working without any visible reason a few times, but this was fixed by rebooting a PC and/or device. Probably SSH session got hung. You could also use qDebug() in C++ code, it does the same:

qDebug() << "Test\n";

If qDebug is working, console.log() should also work.


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 95
Registered: ‎02-23-2011
My Device: Z10 STL100-1
My Carrier: IM3

Re: Console.log doesn't work

I didn't get A in C++ class =P I just skimmed through that. I mean, from the beginning it had already talked about how to see console.log() in the new way, so I thought just going with that could work.

Anyway, I'll tray that tomorrow, maybe will shed some light
BlackBerry Z10