OSDN Git Service

Save log files to the same directory where the output file is located.
authorlordmulder <mulder2@gmx.de>
Sat, 6 May 2017 11:03:12 +0000 (13:03 +0200)
committerlordmulder <mulder2@gmx.de>
Sat, 6 May 2017 11:03:12 +0000 (13:03 +0200)
HISTORY.txt
gui/win_preferences.ui
src/model_logFile.cpp
src/model_logFile.h
src/version.h
src/win_main.cpp

index bb208b8..7ad417f 100644 (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"
index f566eea..ef93eb9 100644 (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>
index 62544b9..bd8de1d 100644 (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))
index f97bd90..83371d6 100644 (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;
index 0a163e3..34af898 100644 (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)
 
index ed48c34..3458502 100644 (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!");
                        }
                }
        }