-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugredirect.cpp
More file actions
46 lines (40 loc) · 1.03 KB
/
debugredirect.cpp
File metadata and controls
46 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <QFile>
#include <QDateTime>
#include <QTextEdit>
//#include "centerwidget.h"
#include "debugredirect.h"
//#define LOGFILENAME "debuglog.txt"
static QFile outFile;
static QTextStream ts;
void messageHandler(QtMsgType type,const char*msg){
#if 1
QString txt;
switch(type){
case QtDebugMsg:
break;
case QtWarningMsg:
txt = QString("Warning:");
break;
case QtCriticalMsg:
txt = QString("Critical:");
break;
case QtFatalMsg:
txt = QString("Fatal:");
abort();
}
txt += QString::fromLocal8Bit(msg);
QString dateTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
#if 0
if(!outFile.isOpen()){
outFile.setFileName(LOGFILENAME);
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
ts.setDevice(&outFile);
}
ts<<dateTime<<endl<<txt<<endl;
#endif
dateTime +="\n";
// QString logTxt = dateTime+" "+txt;
// CenterWidget::updateLog(type,logTxt);
qDebug()<<txt;
#endif
}