qDebug print missplaced in run - not in code sequence
-
I hope I do not get flamed for this post, but I need an answer.
I am using cout and qDebug to trace my code in real time.The attached snippet of code supposedly print qDebug " SINGLE message" first , than cout next.
It does not, see attached console output.
On top of that - the qDebug messages are printed in reverse order.I like to have some explanation why is that.
I actually prefer using cout , and this weird sequence of qDebug makes my way of tracing the code flaky thus unusable.
BUT if that is the way it works, I just won't use it.
ThanksPS
Sorry for messy code , it is work in progressif(BT_string_list.size()) { cout << "ENTRY ********************************************" << endl; #ifdef DEBUG cout << endl; cout << "TRACE Current marker " << __FUNCTION__ << endl; cout << "BT_string_list.size() OK @line list size " << BT_string_list.size() << " " << __LINE__ << endl; // exit(42); cout << "\033[1;31mRED COLOR START " << endl; cout << "\033[1;31mTRACE START \n"; cout << "*** TRACE file " << __FILE__ << endl; cout << " function " << __FUNCTION__ << endl; cout << "COLOR END \033[0m " << dec << __LINE__ << endl; //exit(0); // scan_agent->BTScan_TEST_Print(scan_agent->BTLocalDeviceInfo.name()); // BT_string_list.s cout << "\033[1;32mGREEN COLOR START " << endl; cout << "\033[1;32mTRACE START \n"; cout << "*** TRACE file " << __FILE__ << endl; cout << " function " << __FUNCTION__ << endl; cout << "COLOR END \033[0m " << dec << __LINE__ << endl; //qDebug ("message %d, says: %s",num,str); cout << "***************************************function " << __FUNCTION__ << endl; #ifdef DEBUG cout << "TRACE Current marker " << __FUNCTION__ << endl; cout << "DEBUG HERE @line " << __LINE__ << endl; cout << "function " << __FUNCTION__ << endl; #endif THIS GETS "DELAYED " IN PRINTING TO CONSOLE qDebug() << "SINGLE DEBUG message " << BT_string_list.size()<< ", says: " << BT_string_list.at(0).name() << "@line " << __LINE__; #ifdef DEBUG cout << "TRACE Current marker " << __FUNCTION__ << endl; cout << "DEBUG HERE @line " << __LINE__ << endl; cout << "function " << __FUNCTION__ << endl; #endif //qDebug() << "DEBUG message " << BT_string_list.size()<< ", says: " << BT_string_list.at(1).name(); PRINTS IN CORRECT SEQUENCE cout << "cout test #1 " << BT_string_list.at(0).name().toStdString() << endl; cout <<"cout test #2 " << BT_string_list.at(0).name().toLocal8Bit().constData() << endl; #ifdef DEBUG cout << "TRACE Current marker " << __FUNCTION__ << endl; cout << "DEBUG HERE @line " << __LINE__ << endl; cout << "function " << __FUNCTION__ << endl; #endif #endif cout << "EXIT ******************************************" <<endl; } else
***************************************function on_scan_pressed TRACE Current marker on_scan_pressed DEBUG HERE @line 182 function on_scan_pressed TRACE Current marker on_scan_pressed DEBUG HERE @line 189 function on_scan_pressed PRINTS IN CORRECT SEQUENCE cout test #1 z-desktop cout test #2 z-desktop TRACE Current marker on_scan_pressed DEBUG HERE @line 197 function on_scan_pressed EXIT ****************************************** DEBUG " scan_agent->BTScan_TEST_Print " @line 24 DEBUG "z-desktop" @line 24 DELAYED AND IN REVERSE ORDER OF qDebug calls SINGLE DEBUG message 1 , says: "z-desktop" @line 186 /media/z/DOC_COPY_LABEL/Projects /QT_TEST/TEST_Splitter/application_1/build-application-Desktop-Debug/application exited with code 0
-
I don't see what's wrong here - qDebug() and std::cout are two completely different things so why should the order between those two match when it is printed to stdout?