Commit 0be7647d authored by Mads Bondo Dydensborg's avatar Mads Bondo Dydensborg

Added ability to log from kdenlive_render, if KDENLIVE_RENDER_LOG is set. We...

Added ability to log from kdenlive_render, if KDENLIVE_RENDER_LOG is set. We need this to debug render errors sometimes. Man page update will follow shortly

svn path=/trunk/kdenlive/; revision=3610
parent 33f426b7
......@@ -20,9 +20,13 @@
#include "renderjob.h"
#include <stdlib.h> // for getenv, posix portable to Windows: http://msdn.microsoft.com/en-us/library/tehxacec(VS.80).aspx
#include <QtDBus>
#include <QFile>
#include <QThread>
#include <QStringList>
// Can't believe I need to do this to sleep.
class SleepThread : QThread
......@@ -40,7 +44,8 @@ RenderJob::RenderJob(bool erase, bool usekuiserver, const QString &renderer, con
QObject(),
m_jobUiserver(NULL),
m_kdenliveinterface(NULL),
m_usekuiserver(usekuiserver)
m_usekuiserver(usekuiserver),
m_enablelog( false )
{
m_scenelist = scenelist;
m_dest = dest;
......@@ -67,34 +72,44 @@ RenderJob::RenderJob(bool erase, bool usekuiserver, const QString &renderer, con
connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus)));
m_renderProcess->setReadChannel(QProcess::StandardError);
/*
// Create a log of every render process.
m_logfile.setAutoRemove(false);
m_logfile.setFileTemplate(QDir::tempPath() + "/kdenlive_render.log.XXXXXXXX");
if (m_logfile.open()) {
qDebug() << "Writing render log to " << m_logfile.fileName();
} else {
qDebug() << "Unable to log to " << m_logfile.fileName();
}
m_logstream.setDevice(&m_logfile);
m_logstream << "Log starting. Dumping contents of " << scenelist << endl;
QFile file(scenelist);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
m_logstream << "Unable to read contents of " << scenelist << endl;
} else {
m_logstream.flush();
QTextStream in(&file);
m_logstream << in.readAll() << endl;
m_enablelog = ( getenv( "KDENLIVE_RENDER_LOG" ) != NULL );
if ( m_enablelog ) {
// Create a log of every render process.
m_logfile.setAutoRemove(false);
m_logfile.setFileTemplate(QDir::tempPath() + "/kdenlive_render.log.XXXXXXXX");
if (m_logfile.open()) {
qDebug() << "Writing render log to " << m_logfile.fileName();
} else {
qDebug() << "Unable to log to " << m_logfile.fileName();
}
m_logstream.setDevice(&m_logfile);
QString tmplist = scenelist;
if ( tmplist.contains( "consumer:" ) ) {
QStringList tl = tmplist.split( "consumer:" );
if ( tl.count() == 2 ) {
tmplist = tl[1];
}
}
m_logstream << "Log starting. Dumping contents of " << tmplist << endl;
QFile file(tmplist);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
m_logstream << "Unable to read contents of " << tmplist << endl;
} else {
m_logstream.flush();
QTextStream in(&file);
m_logstream << in.readAll() << endl;
}
}
*/
}
RenderJob::~RenderJob()
{
if (m_renderProcess) delete m_renderProcess;
// m_logfile.close();
if ( m_enablelog ) {
m_logfile.close();
}
}
void RenderJob::slotAbort(const QString& url)
......@@ -119,11 +134,11 @@ void RenderJob::slotAbort()
}
QFile f(m_dest);
f.remove();
/*
m_logstream << "Job aborted by user" << endl;
m_logstream.flush();
m_logfile.close();
*/
if ( m_enablelog ) {
m_logstream << "Job aborted by user" << endl;
m_logstream.flush();
m_logfile.close();
}
qApp->quit();
}
......@@ -132,7 +147,7 @@ void RenderJob::receivedStderr()
QString result = QString(m_renderProcess->readAllStandardError()).simplified();
if (!result.startsWith("Current Frame")) m_errorMessage.append(result + "<br>");
else {
// m_logstream << "ReceivedStderr from melt: " << result << endl;
if ( m_enablelog ) m_logstream << "ReceivedStderr from melt: " << result << endl;
result = result.section(' ', -1);
int pro = result.toInt();
if (pro < 0 || pro > 100) return;
......@@ -169,10 +184,10 @@ void RenderJob::start()
if (interface && m_usekuiserver) {
if (!interface->isServiceRegistered("org.kde.JobViewServer")) {
qDebug() << "No org.kde.JobViewServer registered, trying to start kuiserver";
// m_logstream << "No org.kde.JobViewServer registered, trying to start kuiserver";
if ( m_enablelog ) m_logstream << "No org.kde.JobViewServer registered, trying to start kuiserver";
if (QProcess::startDetached("kuiserver")) {
qDebug() << "Started kuiserver";
// m_logstream << "Started kuiserver";
if ( m_enablelog ) m_logstream << "Started kuiserver";
// Give it a couple of seconds to start
QTime t;
t.start();
......@@ -181,7 +196,7 @@ void RenderJob::start()
}
} else {
qDebug() << "Failed to start kuiserver";
// m_logstream << "Failed to start kuiserver";
if ( m_enablelog ) m_logstream << "Failed to start kuiserver";
}
}
......@@ -205,7 +220,7 @@ void RenderJob::start()
// Because of the logging, we connect to stderr in all cases.
connect(m_renderProcess, SIGNAL(readyReadStandardError()), this, SLOT(receivedStderr()));
m_renderProcess->start(m_prog, m_args);
// m_logstream << "Started render process: " << m_prog << " " << m_args.join(" ") << endl;
if ( m_enablelog ) m_logstream << "Started render process: " << m_prog << " " << m_args.join(" ") << endl;
qDebug() << "Started render process: " << m_prog << " " << m_args.join(" ");
}
......@@ -256,7 +271,7 @@ void RenderJob::slotIsOver(int /*exitcode*/, QProcess::ExitStatus status)
}
QStringList args;
args << "--error" << tr("Rendering of %1 aborted, resulting video will probably be corrupted.").arg(m_dest);
// m_logstream << "Rendering of " << m_dest << " aborted, resulting video will probably be corrupted." << endl;
if ( m_enablelog ) m_logstream << "Rendering of " << m_dest << " aborted, resulting video will probably be corrupted." << endl;
qDebug() << "Rendering of " << m_dest << " aborted, resulting video will probably be corrupted.";
QProcess::startDetached("kdialog", args);
qApp->quit();
......@@ -287,10 +302,10 @@ void RenderJob::slotIsOver(int /*exitcode*/, QProcess::ExitStatus status)
m.setArguments(args);
QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
}
// m_logstream << "Rendering of " << m_dest << " finished" << endl;
if ( m_enablelog ) m_logstream << "Rendering of " << m_dest << " finished" << endl;
qDebug() << "Rendering of " << m_dest << " finished";
if (!m_dualpass && m_player != "-") {
// m_logstream << "Starting player" << endl;
if ( m_enablelog ) m_logstream << "Starting player" << endl;
QStringList args;
args << m_dest;
QProcess::startDetached(m_player, args);
......
......@@ -63,6 +63,11 @@ private:
QTime m_startTime;
void initKdenliveDbusInterface();
bool m_usekuiserver;
bool m_enablelog;
/** \brief Used to create a temporary file for logging */
QTemporaryFile m_logfile;
/** \brief Used to write to the log file */
QTextStream m_logstream;
signals:
void renderingFinished();
......
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