Changeset 54:03426342db84 in SMSSender


Ignore:
Timestamp:
Jan 30, 2010 3:22:22 PM (9 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@53
Message:
  • qDebug() saved into a file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cpp

    r44 r54  
    1313
    1414//Q_IMPORT_PLUGIN(interfaces)
     15
     16#include <iostream>
     17#include <fstream>
     18
     19using namespace std;
     20
     21ofstream logfile;
     22
     23void MyOutputHandler(QtMsgType type, const char *msg) {
     24    switch (type) {
     25        case QtDebugMsg:
     26            logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n";
     27            break;
     28        case QtCriticalMsg:
     29            logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n";
     30            break;
     31        case QtWarningMsg:
     32            logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n";
     33            break;
     34        case QtFatalMsg:
     35            logfile << QTime::currentTime().toString().toAscii().data() <<  " Fatal: " << msg << "\n";
     36            abort();
     37    }
     38}
     39
    1540
    1641void loadGateways() {
     
    4873
    4974int main(int argc, char *argv[]){
     75    logfile.open("logfile.txt", ios::app);
     76    #ifndef QT_NO_DEBUG_OUTPUT
     77    qInstallMsgHandler(MyOutputHandler);
     78    #endif
     79
     80
    5081    QApplication a(argc, argv);
    5182
Note: See TracChangeset for help on using the changeset viewer.