-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.cpp
More file actions
55 lines (45 loc) · 1.16 KB
/
logging.cpp
File metadata and controls
55 lines (45 loc) · 1.16 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
47
48
49
50
51
52
53
54
55
#include "logging.h"
#ifndef Q_OS_WIN32
#include <syslog.h>
#endif
#include <QByteArray>
#include <QString>
#ifdef Q_OS_WIN32
#include <stdio.h>
#include <stdarg.h>
void syslog(int priority, const char *format, ...){
Q_UNUSED(priority);
va_list arg_list;
va_start(arg_list, format);
vprintf(format, arg_list);
va_end(arg_list);
}
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
void qtOutputToLog(QtMsgType type, const QMessageLogContext &context, const QString &m)
{
Q_UNUSED(context);
QByteArray localMsg = m.toLocal8Bit();
const char *msg = localMsg.constData();
#else
void qtOutputToLog(QtMsgType type, const char *msg)
{
#endif
switch(type){
case QtDebugMsg:
syslog(LOG_DEBUG, "Qt debug: %s", msg);
break;
case QtWarningMsg:
syslog(LOG_WARNING, "Qt warning: %s", msg);
break;
case QtCriticalMsg:
syslog(LOG_CRIT, "Qt critical: %s", msg);
break;
case QtFatalMsg:
syslog(LOG_ALERT, "Qt fatal: %s", msg);
break;
default:
syslog(LOG_INFO, "Qt info: %s", msg);
break;
}
}