Logger should also output to stderr

This commit is contained in:
Adam Treat 2023-06-01 14:14:06 -04:00
parent 022f1cabe7
commit 20eff29432

View File

@ -4,6 +4,7 @@
#include <QDebug>
#include <QStandardPaths>
#include <QDateTime>
#include <iostream>
class MyLogger: public Logger { };
Q_GLOBAL_STATIC(MyLogger, loggerInstance)
@ -56,6 +57,9 @@ void Logger::messageHandler(QtMsgType type, const QMessageLogContext &, const QS
// Get time and date
auto timestamp = QDateTime::currentDateTime().toString();
// Write message
logger->m_file.write(QString("[%1] (%2): %4\n").arg(typeString, timestamp, msg).toStdString().c_str());
const std::string out = QString("[%1] (%2): %4\n").arg(typeString, timestamp, msg).toStdString();
logger->m_file.write(out.c_str());
logger->m_file.flush();
std::cerr << out;
fflush(stderr);
}