-
Notifications
You must be signed in to change notification settings - Fork 0
/
qsdebug.h
53 lines (44 loc) · 1.19 KB
/
qsdebug.h
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
47
48
49
50
51
52
53
#ifndef QSDEBUG_H
#define QSDEBUG_H
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QDir>
namespace qsDebug
{
/**
* message handler, will output debug, warning, critical and fatal to file
*
* @param message type
* @param message
*/
static void debugOutput(QtMsgType type, const char *msg)
{
QFile file;
file.setFileName( "quotesee_debug.log" );
QDir::setCurrent(QDir::homePath());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
return;
QTextStream out(&file);
switch (type)
{
case QtDebugMsg:
out << "Debug:\t";
out << msg << endl;
break;
case QtWarningMsg:
out << "Warning:\t";
out << msg << endl;
break;
case QtCriticalMsg:
out << "Critical:\t";
out << msg << endl;
break;
case QtFatalMsg:
out << "Fatal:\t";
out << msg << endl;
abort();
}
file.close();
}
};
#endif // QSDEBUG_H