I am using tizen IDE 2.4.0_Rev5 for development and running my apps on the Tizen TV emulator. The problem I am facing is that many of logs which have been put in the javascript file( using console.log('xyz') ) do not appear in the console while running the app or even if I launch the debugger, however some logs do come.
For instance, I took the sample App for AV Player from here: https://github.com/Samsung/TizenTVApps/tree/master/TVDemoAvPlayer
When I run the app, I and press play button, I get only the following logs:
js/main.js (218) :Buffering Complete, Can play now!
js/main.js (66) :PLAYPAUSE
js/main.js (149) :Player.play(undefined)
However, if you look at the file, there are many logs which do not come, for instance:
console.log('Main.onLoad()');
console.log('Player.init('+id+')');
console.log('Player.prepare('+url+')');
If you look at the code, it is certain that the control will reach these points (I also verfied by making some modification-- change the url etc and it takes affect), therefore it makes no sense at all for these logs not coming and indicates that either I have missed some setting/configuration or there is some major issue with the SDK/emulator.
Has anyone faced similar issue while working on Tizen TV emulator? Is there any way to resolve it?
You're not doing anything wrong. I struggled with the same issue in the beginning. Unfortunately with the way Samsung has set up their debugging environment, some of your logs are being outputted before the console window is ready. We have found a few solutions for this. All of them work if you are debugging in the emulator or on an actual tv.
This simplest solution is to type location.reload()
in the console once your app has started. The will restart the app without restarting the debugger. This way you will be able to see all of your logs. Be warned that we've seen some odd behavior after the reload, so do not rely on this for proper debugging. But it's still an effective "quick and dirty" method to see the logs from the beginning.
The next solution is to write some code to override console.log()
in order to cache the messages. Then you can call a function from the console to playback the messages. Something like this will keep the last 200 log lines, and allow you to output them by calling dumpLog()
. (The sample code below relies on lodash.)
var proxiedLog = console.log;
var logCache = [];
console.log = function() {
logCache.push(_.join(arguments, ", "));
_.drop(logCache, logCache.length - 200);
return proxiedLog.apply(this, arguments);
}
function dumpLog() {
_.forEach(logCache, function(entry) { console.debug(JSON.stringify(entry)); });
}
But the best way, the way I would encourage you to setup before you release into production, is to send that information to a backend service which caches the logs for you. You can use a similar setup to the one above, you just need to also send the output to your server. Be sure to include some unique identifier so you can distinguish logs from different devices.
Hope this helps.