1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

add logging to file; should make bug reports easier to handle

(it's a bit of a hack, but it works)
This commit is contained in:
dubslow 2014-11-01 00:27:10 -05:00
parent 973904addd
commit b78737632e
2 changed files with 27 additions and 1 deletions

View File

@ -49,8 +49,9 @@ TRANSLATIONS = translations/de.ts \
RESOURCES += res.qrc
GIT_VERSION = $$system(git rev-parse HEAD 2> /dev/null || echo "(built without git)")
GIT_VERSION = $$system(git rev-parse HEAD 2> /dev/null || echo "built without git")
DEFINES += GIT_VERSION=\\\"$$GIT_VERSION\\\"
DEFINES += LOG_TO_FILE
contains(JENKINS,YES) {
INCLUDEPATH += ./libs/include/

View File

@ -19,6 +19,21 @@
#include <QApplication>
#include <QFontDatabase>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QDateTime>
#ifdef LOG_TO_FILE
static QtMessageHandler dflt;
static QTextStream logFile;
void myMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QString& msg)
{
dflt(type, ctxt, msg);
logFile << QTime::currentTime().toString("HH:mm:ss' '") << msg << '\n';
logFile.flush();
}
#endif
int main(int argc, char *argv[])
{
@ -26,6 +41,16 @@ int main(int argc, char *argv[])
a.setApplicationName("qTox");
a.setOrganizationName("Tox");
#ifdef LOG_TO_FILE
dflt = qInstallMessageHandler(nullptr);
QFile logfile(QDir(Settings::getSettingsDirPath()).filePath("qtox.log"));
logfile.open(QIODevice::Append);
logFile.setDevice(&logfile);
logFile << QDateTime::currentDateTime().toString("yyyy-dd-MM HH:mm:ss' file logger starting\n'");
qInstallMessageHandler(myMessageHandler);
#endif
// Windows platform plugins DLL hell fix
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
a.addLibraryPath("platforms");