1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-23 21:07:45 +00:00
astra/launcher/src/processlogger.cpp

33 lines
1.1 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "processlogger.h"
#include "astra_log.h"
#include "utility.h"
2023-12-31 17:23:55 -05:00
#include <QStandardPaths>
ProcessLogger::ProcessLogger(QProcess *process)
{
2023-12-31 17:23:55 -05:00
const QDir dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
const QDir logDirectory = dataDir.absoluteFilePath(QStringLiteral("log"));
m_file.setFileName(logDirectory.absoluteFilePath(QStringLiteral("ffxiv.log")));
m_file.open(QIODevice::WriteOnly | QIODevice::Unbuffered);
connect(process, &QProcess::readyReadStandardOutput, this, [this, process] {
m_file.write(process->readAllStandardOutput());
m_file.flush();
});
connect(process, &QProcess::readyReadStandardError, this, [this, process] {
m_file.write(process->readAllStandardError());
m_file.flush();
});
connect(process, &QProcess::finished, this, [this] {
deleteLater();
});
qInfo(ASTRA_LOG) << "Client logs are being written to" << m_file.fileName().toUtf8().constData();
}