Created
April 11, 2019 17:27
-
-
Save wspeirs/9d47359809780974de6cb02ac7120d57 to your computer and use it in GitHub Desktop.
Example of how to use logging in QT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mainwindow.h" | |
#include <QApplication> | |
#include <QFile> | |
#include <QDebug> | |
#include <QLoggingCategory> | |
Q_LOGGING_CATEGORY(fcIo, "fc.io") | |
int main(int argc, char *argv[]) | |
{ | |
QApplication a(argc, argv); | |
// QString file_loc = "/tmp/dbg.txt"; | |
// QFile *dbg_file = new QFile(file_loc); | |
// dbg_file->open(QIODevice::WriteOnly); | |
// QDebug dbg(dbg_file); | |
// qDebug() << "HELLO WORLD" << endl; | |
QLoggingCategory::setFilterRules("*.debug=false\n" "fc.io.debug=true"); | |
// QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true); | |
qCDebug(fcIo, "Loading highscore ..."); | |
qDebug() << "Test"; | |
MainWindow mw; | |
mw.show(); | |
return a.exec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment