Skip to content

Instantly share code, notes, and snippets.

@SeeLook
Created December 25, 2015 11:11
Function handling debug messages to file
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