您的位置:首页 > 其它

问题:如何qDebug自己开发的运行在BlackBerry 10的Work Space中的企业应用呢?

2013-04-16 10:22 681 查看
要知道,在Work Space中运行的企业应用,是通过BDS服务器推送下来的,Cascade IDE是连不上去做debug的。
而且,你也没有办法到/accounts/1000/appdata/myappxxxxxx/logs下面看到企业应用的log。

思路:在Cascade/Qt主程序中,重定向qDebug输出到console和/tmp/ddemo_console.txt文件,那么我就可以用IDE ssh连到手机上面,查看这个文本文件看日志了。

step 1)编辑主程序代码,输出文本到console和/tmp/ddemo_console.txt文件
void myMessageOutput(QtMsgType type, const char* msg) {
/* print debug message to IDE console */
std::fprintf(stdout, "%s\n", msg);
std::fflush(stdout);

QString text;
switch (type)
{
case QtDebugMsg:
text = QString("Debug: %1").arg(msg);
break;
case QtWarningMsg:
text = QString("Warning: %1").arg(msg);
break;
case QtCriticalMsg:
text = QString("Critical: %1").arg(msg);
break;
case QtFatalMsg:
text = QString("Fatal: %1").arg(msg);
break;
}

/* print debug message to file /tmp/ddemo_console.txt */
QFile file("/tmp/ddemo_console.txt");
file.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream ts(&file);
ts<<text<<endl;
file.close();

std::fflush(stdout);

}

step 2)在程序的main()方法中重定向qDebug()输出
qInstallMsgHandler(myMessageOutput);

step 3)应用中,用qDebug输出调试信息,比如 
#include <QDebug>

qDebug()<< "Trying to start the demo.";

step 4)编译签名应用,上传到BDS服务器,从服务器上面推送安装应用到手机上。

step 5)手机启用开发者模式,PC机上用IDE ssh连接到手机,查看/tmp/ddemo_console.txt文件。
tail -f /tmp/ddemo_console.txt
----------------------------------------------

参考:https://developer.blackberry.com/cascades/download/releasenotes/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: