I am using this code
void myMessageHandler(QtMsgType type, const char *msg)
{
txt = msg;
txt.prepend(" - ");
txt.prepend(date.currentDateTime().toString());
QFile outFile
("log.txt");
ts << txt <<endl<<flush;
}
int main(int argc, char *argv[])
{
qInstallMsgHandler(myMessageHandler);
MainWindow w;
return a.exec();
}
void myMessageHandler(QtMsgType type, const char *msg)
{
QString txt;
QDateTime date;
txt = msg;
txt.prepend(" - ");
txt.prepend(date.currentDateTime().toString());
QFile outFile("log.txt");
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream ts(&outFile);
ts << txt <<endl<<flush;
}
int main(int argc, char *argv[])
{
qInstallMsgHandler(myMessageHandler);
QApplication a(argc, argv);
MainWindow w;
return a.exec();
}
To copy to clipboard, switch view to plain text mode
I am able to get all the data in 1 line
Tue Jul 14 10:15:54 2009 - i am in debug
Tue Jul 14 10:16:06 2009 - i am in debug
One more question, will qDebug work only if the app is built in debug mode??
Bookmarks