1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

[OP-835] Qt 5.1.0 - GCS will now write log file to temporay directory in Release builds (currenlty disabled)

This commit is contained in:
Philippe Renon 2013-09-15 22:04:43 +02:00
parent 5ced372f7d
commit 221cc6557a

View File

@ -259,6 +259,17 @@ void systemInit()
#endif
}
void logInit()
{
qInstallMessageHandler(mainMessageOutput);
QFile file(QDir::tempPath() + "/gcs.log");
if (file.exists()) {
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
// erase old log
}
}
}
inline QStringList getPluginPaths()
{
QStringList rc;
@ -405,6 +416,35 @@ void loadTranslators(QString language, QTranslator &translator, QTranslator &qtT
}
}
}
void mainMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QFile file(QDir::tempPath() + "/gcs.log");
if (file.open(QIODevice::Append | QIODevice::Text)) {
QTextStream out(&file);
out << QTime::currentTime().toString("hh:mm:ss.zzz ");
switch (type) {
case QtDebugMsg:
out << "DBG: ";
break;
case QtWarningMsg:
out << "WRN: ";
break;
case QtCriticalMsg:
out << "CRT: ";
break;
case QtFatalMsg:
out << "FTL: ";
break;
}
out << msg << '\n';
out.flush();
}
}
} // namespace anonymous
int main(int argc, char * *argv)
@ -416,6 +456,10 @@ int main(int argc, char * *argv)
// low level init
systemInit();
#ifdef QT_NO_DEBUG
// logInit();
#endif
// create application
SharedTools::QtSingleApplication app(APP_NAME, argc, argv);