Commit 37828fb1 authored by Mehdi Fekari's avatar Mehdi Fekari Committed by Christian Kandeler

QNX: Fix logs output

Change-Id: I6841638341f80e2f13d14cc49190652be2bf82a0
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
parent 31b135a4
......@@ -93,6 +93,7 @@ BlackBerryApplicationRunner::BlackBerryApplicationRunner(bool debugMode, BlackBe
, m_stopProcess(0)
, m_tailProcess(0)
, m_testSlog2Process(0)
, m_launchDateTimeProcess(0)
, m_runningStateTimer(new QTimer(this))
, m_runningStateProcess(0)
{
......@@ -146,8 +147,9 @@ void BlackBerryApplicationRunner::start()
void BlackBerryApplicationRunner::checkSlog2Info()
{
// Not necessary to retest if slog2info exists.
if (!m_testSlog2Process) {
if (m_testSlog2Process) {
readLaunchTime();
} else if (!m_testSlog2Process) {
m_testSlog2Process = new QSsh::SshRemoteProcessRunner(this);
connect(m_testSlog2Process, SIGNAL(processClosed(int)),
this, SLOT(handleSlog2InfoFound()));
......@@ -270,7 +272,11 @@ void BlackBerryApplicationRunner::killTailProcess()
void BlackBerryApplicationRunner::tailApplicationLog()
{
// TODO: Reading the log using qconn instead?
QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender());
QTC_ASSERT(process, return);
m_launchDateTime = QDateTime::fromString(QString::fromLatin1(process->readAllStandardOutput()).trimmed(),
QString::fromLatin1("dd HH:mm:ss"));
if (m_stopping || (m_tailProcess && m_tailProcess->isProcessRunning()))
return;
......@@ -290,7 +296,7 @@ void BlackBerryApplicationRunner::tailApplicationLog()
QString command;
if (m_slog2infoFound) {
command = QString::fromLatin1("slog2info -w");
command = QString::fromLatin1("slog2info -w -b ") + m_appId;
} else {
command = QLatin1String("tail -c +1 -f /accounts/1000/appdata/") + m_appId
+ QLatin1String("/logs/log");
......@@ -308,6 +314,15 @@ void BlackBerryApplicationRunner::handleSlog2InfoFound()
tailApplicationLog();
}
void BlackBerryApplicationRunner::readLaunchTime()
{
m_launchDateTimeProcess = new QSsh::SshRemoteProcessRunner(this);
connect(m_launchDateTimeProcess, SIGNAL(processClosed(int)),
this, SLOT(tailApplicationLog()));
m_launchDateTimeProcess->run("date +\"%d %H:%M:%S\"", m_sshParams);
}
void BlackBerryApplicationRunner::handleTailOutput()
{
QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender());
......@@ -317,7 +332,9 @@ void BlackBerryApplicationRunner::handleTailOutput()
if (m_slog2infoFound) {
const QStringList multiLine = message.split(QLatin1Char('\n'));
Q_FOREACH (const QString &line, multiLine) {
if ( line.contains(m_appId) ) {
QDateTime dateTime = QDateTime::fromString(line.split(m_appId).first().mid(4).trimmed(),
QString::fromLatin1("dd HH:mm:ss.zzz"));
if (dateTime >= m_launchDateTime) {
QStringList validLineBeginnings;
validLineBeginnings << QLatin1String("qt-msg 0 ")
<< QLatin1String("qt-msg* 0 ")
......
......@@ -39,6 +39,7 @@
#include <QObject>
#include <QProcess>
#include <QDateTime>
namespace QSsh {
class SshRemoteProcessRunner;
......@@ -89,6 +90,7 @@ private slots:
void readRunningStateStandardOutput();
void handleSlog2InfoFound();
void readLaunchTime();
private:
void reset();
......@@ -97,6 +99,8 @@ private:
bool m_debugMode;
bool m_slog2infoFound;
QDateTime m_launchDateTime;
qint64 m_pid;
QString m_appId;
......@@ -114,6 +118,7 @@ private:
QProcess *m_stopProcess;
QSsh::SshRemoteProcessRunner *m_tailProcess;
QSsh::SshRemoteProcessRunner *m_testSlog2Process;
QSsh::SshRemoteProcessRunner *m_launchDateTimeProcess;
QTimer *m_runningStateTimer;
QProcess *m_runningStateProcess;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment