在三星Tizen TV模拟器中无法获取正确的日志 [英] Not getting proper logs in Samsung Tizen TV emulator

查看:204
本文介绍了在三星Tizen TV模拟器中无法获取正确的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的问题 IDE 2.4.0_Rev5开发和在Tizen TV模拟器上运行我的应用程序. 我面临的问题是,在运行应用程序时,即使我已经将许多日志(使用 console.log('xyz'))放置在javascript文件中,即使我启动调试器,但是确实有一些日志.

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.

例如,我从此处获取了用于AV Player的示例应用程序: https://github.com/Samsung/TizenTVApps/tree/master/TVDemoAvPlayer

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+')');

如果您查看代码,则可以确定控件将达到这些点(我也通过进行一些修改来验证-更改url等会生效),因此对于这些日志根本没有任何意义.没有出现,表示我错过了某些设置/配置,或者SDK/仿真器存在一些重大问题.

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.

在Tizen TV模拟器上工作时,有人遇到过类似的问题吗?有什么办法解决吗?

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.

最简单的解决方案是在启动应用后在控制台中键入location.reload().将重新启动应用程序,而无需重新启动调试器.这样,您将能够查看所有日志.请注意,重新加载后我们已经看到了一些奇怪的行为,因此请不要依赖于此进行适当的调试.但是从一开始就查看日志仍然是一种有效的快速而肮脏"的方法.

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.

下一个解决方案是编写一些代码来覆盖console.log()以便缓存消息.然后,您可以从控制台调用一个函数来播放消息.这样的事情将保留最后200条日志行,并允许您通过调用dumpLog()将其输出. (下面的示例代码依赖于 lodash .)

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.

希望这会有所帮助.

这篇关于在三星Tizen TV模拟器中无法获取正确的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆