Logger should also output to stderr

pull/800/head
Adam Treat 12 months ago
parent 022f1cabe7
commit 20eff29432

@ -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);
}

Loading…
Cancel
Save