dkonigsberg icon

QDebug Hook

dkonigsberg | PRO | 09/29/12 11:33:56 PM UTC | 0 ⭐ | 10253 👁️ | Never ⏰ | []
C++ (with Qt extensions) |

0 B

|

None

|

0 👍

/

0 👎

#ifndef QT_NO_DEBUG_OUTPUT
void logMessageHandler(QtMsgType type, const char *msg)
{
    QString debugdate = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
    switch (type)
    {
    case QtDebugMsg:
        debugdate += "[D]";
        break;
    case QtWarningMsg:
        debugdate += "[W]";
        break;
    case QtCriticalMsg:
        debugdate += "[C]";
        break;
    case QtFatalMsg:
        debugdate += "[F]";
        break;
    }
 
    fprintf(stderr, "%s %s\n", debugdate.toLatin1().data(), msg);
 
    if (QtFatalMsg == type) {
        abort();
    }
}
#endif
 
int main(int argc, char **argv)
{
#ifndef QT_NO_DEBUG_OUTPUT
    qInstallMsgHandler(logMessageHandler);
#endif
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎