Not getting proper logs in Samsung Tizen TV emulator

余生颓废 提交于 2019-12-02 05:51:11

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!