Created
December 25, 2015 11:11
Function handling debug messages to file
This file contains 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
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { | |
Q_UNUSED(context) | |
Q_UNUSED(type) | |
QFile outFile(qgetenv("EXTERNAL_STORAGE") + QStringLiteral("/myApp-log.txt")); | |
// EXTERNAL_STORAGE determines writable inner storage of device, for memory card use SECONDARY_STORAGE, but it may not exists | |
if (outFile.open(QIODevice::WriteOnly | QIODevice::Append)) { // append line by line | |
QTextStream ts(&outFile); | |
ts << msg << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment