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:
parent
973904addd
commit
b78737632e
3
qtox.pro
3
qtox.pro
|
@ -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/
|
||||
|
|
25
src/main.cpp
25
src/main.cpp
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue
Block a user