Save log files to the same directory where the output file is located.

This commit is contained in:
LoRd_MuldeR 2017-05-06 13:03:12 +02:00
parent 882c6df144
commit a34a9b8b61
6 changed files with 28 additions and 16 deletions

View File

@ -5,6 +5,7 @@ Simple x264/x265 Launcher version history
Version 2.81 [2017-??-??]
* Updated x265 to version 2.3+32
* Updated NVEncC to version 3.07
* Save log files to the same directory as the output file
Version 2.80 [2017-04-01]
* Another attempt to fix application startup error "0xc0000005"

View File

@ -172,7 +172,7 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
<item>
<widget class="QLabel" name="labelSaveLogFiles">
<property name="text">
<string>Automatically save output to log file when a job has finished</string>
<string>Automatically create a log file when the job has finished</string>
</property>
</widget>
</item>

View File

@ -101,7 +101,7 @@ QVariant LogFileModel::data(const QModelIndex &index, int role) const
// Public API
///////////////////////////////////////////////////////////////////////////////
void LogFileModel::copyToClipboard(void)
void LogFileModel::copyToClipboard(void) const
{
QClipboard *const clipboard = QApplication::clipboard();
QStringList buffer;
@ -113,7 +113,7 @@ void LogFileModel::copyToClipboard(void)
clipboard->setText(buffer.join("\r\n"));
}
bool LogFileModel::saveToLocalFile(const QString &fileName)
bool LogFileModel::saveToLocalFile(const QString &fileName) const
{
QFile file(fileName);
if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate))

View File

@ -43,8 +43,8 @@ public:
virtual QModelIndex parent (const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
void copyToClipboard(void);
bool saveToLocalFile(const QString &fileName);
void copyToClipboard(void) const;
bool saveToLocalFile(const QString &fileName) const;
protected:
bool m_firstLine;

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 8
#define VER_X264_PATCH 0
#define VER_X264_BUILD 1106
#define VER_X264_BUILD 1107
#define VER_X264_PORTABLE_EDITION (0)

View File

@ -733,20 +733,31 @@ void MainWindow::saveLogFile(const QModelIndex &index)
{
if(index.isValid())
{
if(LogFileModel *log = m_jobList->getLogFile(index))
const LogFileModel *const logData = m_jobList->getLogFile(index);
const QString &outputFilePath = m_jobList->getJobOutputFile(index);
if(logData && (!outputFilePath.isEmpty()))
{
const QString outputDir = QString("%1/logs").arg(x264_data_path());
const QString timeStamp = QDateTime::currentDateTime().toString("yyyy-MM-dd.HH-mm-ss");
QDir(outputDir).mkpath(".");
const QString logFilePath = MUtils::make_unique_file(outputDir, QString("LOG.%1").arg(timeStamp), QLatin1String("txt"));
if(logFilePath.isEmpty())
const QFileInfo outputFileInfo(outputFilePath);
if (outputFileInfo.absoluteDir().exists())
{
qWarning("Failed to generate log file name. Giving up!");
return;
const QString outputDir = outputFileInfo.absolutePath(), outputName = outputFileInfo.fileName();
const QString logFilePath = MUtils::make_unique_file(outputDir, outputName, QLatin1String("log"), true);
if (!logFilePath.isEmpty())
{
qDebug("Saving log file to: \"%s\"", MUTILS_UTF8(logFilePath));
if (!logData->saveToLocalFile(logFilePath))
{
qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
}
}
else
{
qWarning("Failed to generate log file name. Giving up!");
}
}
if(!log->saveToLocalFile(logFilePath))
else
{
qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
qWarning("Output directory does not seem to exist. Giving up!");
}
}
}