Copy log files to crash report directory
Signed-off-by: Max Risuhin <risuhin.max@gmail.com>
This commit is contained in:
parent
252d09ee05
commit
aa949c64e3
|
@ -167,6 +167,19 @@ void exceptionPostHandledCallback() {
|
|||
#endif
|
||||
}
|
||||
|
||||
QString getDataStoragePath() {
|
||||
QString dataStoragePath;
|
||||
#ifdef BUILD_FOR_BUNDLE
|
||||
dataStoragePath =
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
QDir dir(dataStoragePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
#endif
|
||||
return dataStoragePath;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
@ -179,9 +192,9 @@ int main(int argc, char **argv) {
|
|||
appPath.append(CRASH_REPORT_EXECUTABLE_RELATIVE_PATH);
|
||||
#endif
|
||||
|
||||
ExceptionGlobalHandler exceptionHandler(appPath + QDir::separator() +
|
||||
CRASH_REPORT_EXECUTABLE,
|
||||
exceptionPostHandledCallback);
|
||||
ExceptionGlobalHandler exceptionHandler(
|
||||
appPath + QDir::separator() + CRASH_REPORT_EXECUTABLE,
|
||||
exceptionPostHandledCallback, getDataStoragePath());
|
||||
|
||||
Q_INIT_RESOURCE(react_resources);
|
||||
|
||||
|
@ -243,16 +256,6 @@ int main(int argc, char **argv) {
|
|||
|
||||
#ifdef BUILD_FOR_BUNDLE
|
||||
|
||||
QString getDataStoragePath() {
|
||||
QString dataStoragePath =
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
QDir dir(dataStoragePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
return dataStoragePath;
|
||||
}
|
||||
|
||||
void writeLogsToFile() {
|
||||
QMutexLocker locker(&consoleOutputMutex);
|
||||
QFile logFile(getDataStoragePath() + "/StatusIm.log");
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
|
||||
const int MAIN_WINDOW_WIDTH = 1024;
|
||||
const int MAIN_WINDOW_HEIGHT = 768;
|
||||
const int INPUT_ARGUMENTS_COUNT = 5;
|
||||
const int INPUT_ARGUMENTS_COUNT = 6;
|
||||
|
||||
const int MINIDUMP_FILE_PATH_ARG_INDEX = 1;
|
||||
const int CRASHED_EXECUTABLE_PATH_ARG_INDEX = 2;
|
||||
const int LOGS_PATH_INDEX = 5;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -30,7 +34,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
app.setApplicationName("Crash Report");
|
||||
|
||||
ReportPublisher reportPublisher(argv[1], argv[2]);
|
||||
ReportPublisher reportPublisher(argv[MINIDUMP_FILE_PATH_ARG_INDEX],
|
||||
argv[CRASHED_EXECUTABLE_PATH_ARG_INDEX],
|
||||
argv[LOGS_PATH_INDEX]);
|
||||
|
||||
QQuickView view;
|
||||
view.rootContext()->setContextProperty("reportPublisher", &reportPublisher);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QUrl>
|
||||
|
@ -22,9 +23,10 @@ const QString REPORT_SUBMIT_URL =
|
|||
QStringLiteral("https://goo.gl/forms/0705ZN0EMW3xLDpI2");
|
||||
|
||||
ReportPublisher::ReportPublisher(QString minidumpFilePath,
|
||||
QString crashedExecutablePath, QObject *parent)
|
||||
QString crashedExecutablePath,
|
||||
QString logsPath, QObject *parent)
|
||||
: QObject(parent), m_minidumpFilePath(minidumpFilePath),
|
||||
m_crashedExecutablePath(crashedExecutablePath) {}
|
||||
m_logsPath(logsPath), m_crashedExecutablePath(crashedExecutablePath) {}
|
||||
|
||||
void ReportPublisher::submit() {
|
||||
QDesktopServices::openUrl(QUrl(REPORT_SUBMIT_URL));
|
||||
|
@ -73,7 +75,21 @@ bool ReportPublisher::prepareReportFiles(QString reportDirPath) {
|
|||
reportDirPath + QDir::separator() + "crash.dmp") &&
|
||||
QFile::copy(m_crashedExecutablePath,
|
||||
reportDirPath + QDir::separator() +
|
||||
crashedExecutableFileInfo.fileName());
|
||||
crashedExecutableFileInfo.fileName()) &&
|
||||
prepareLogFiles(reportDirPath);
|
||||
}
|
||||
|
||||
bool ReportPublisher::prepareLogFiles(QString reportDirPath) {
|
||||
if (reportDirPath.isEmpty())
|
||||
return true;
|
||||
|
||||
QDirIterator filesIterator(m_logsPath, QStringList() << "*.log", QDir::Files);
|
||||
while (filesIterator.hasNext()) {
|
||||
QFileInfo logFile(filesIterator.next());
|
||||
QFile::copy(logFile.absoluteFilePath(),
|
||||
reportDirPath + QDir::separator() + logFile.fileName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString ReportPublisher::resolveDataStoragePath() {
|
||||
|
|
|
@ -15,25 +15,26 @@
|
|||
#include <QString>
|
||||
|
||||
class ReportPublisher : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReportPublisher(QString minidumpFilePath, QString crashedExecutablePath, QObject* parent = 0);
|
||||
ReportPublisher(QString minidumpFilePath, QString crashedExecutablePath,
|
||||
QString logsPath, QObject *parent = 0);
|
||||
|
||||
Q_INVOKABLE void submit();
|
||||
Q_INVOKABLE void restartAndQuit();
|
||||
Q_INVOKABLE void quit();
|
||||
Q_INVOKABLE void showDirectory();
|
||||
Q_INVOKABLE QString resolveDataStoragePath();
|
||||
Q_INVOKABLE void submit();
|
||||
Q_INVOKABLE void restartAndQuit();
|
||||
Q_INVOKABLE void quit();
|
||||
Q_INVOKABLE void showDirectory();
|
||||
Q_INVOKABLE QString resolveDataStoragePath();
|
||||
|
||||
private:
|
||||
bool prepareReportFiles(QString reportDirPath);
|
||||
bool prepareLogFiles(QString reportDirPath);
|
||||
|
||||
bool prepareReportFiles(QString reportDirPath);
|
||||
|
||||
QString m_minidumpFilePath;
|
||||
QString m_crashedExecutablePath;
|
||||
bool m_logFilesPrepared = false;
|
||||
QString m_minidumpFilePath;
|
||||
QString m_crashedExecutablePath;
|
||||
QString m_logsPath;
|
||||
bool m_logFilesPrepared = false;
|
||||
};
|
||||
|
||||
|
||||
#endif // REPORTPUBLISHER
|
||||
|
|
Loading…
Reference in New Issue