~unity-2d-team/unity-2d/dash-not-dock

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/unity2ddebug.cpp

  • Committer: Aurelien Gateau
  • Date: 2011-03-07 14:52:11 UTC
  • mto: This revision was merged to the branch mainline in revision 446.
  • Revision ID: aurelien.gateau@canonical.com-20110307145211-b0cu1t3gx1wp91sz
Moved qt message handling to unity2ddebug

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
// Local
25
25
 
26
26
// Qt
 
27
#include <QCoreApplication>
27
28
 
28
29
// Glib
29
30
#include <glib.h>
30
31
 
 
32
// libc
 
33
#include <cstdio>
 
34
#include <cstdlib>
 
35
 
31
36
namespace Unity2dDebug
32
37
{
33
38
 
 
39
static void unity2dQtHandler(QtMsgType type, const char *message)
 
40
{
 
41
    static QByteArray name = QCoreApplication::applicationFilePath().section("/", -1).toLocal8Bit();
 
42
    switch (type) {
 
43
    case QtDebugMsg:
 
44
        fprintf(stderr, "%s: [DEBUG] %s\n", name.constData(), message);
 
45
        break;
 
46
    case QtWarningMsg:
 
47
        fprintf(stderr, "%s: [WARNING] %s\n", name.constData(), message);
 
48
        break;
 
49
    case QtCriticalMsg:
 
50
        fprintf(stderr, "%s: [CRITICAL] %s\n", name.constData(), message);
 
51
        break;
 
52
    case QtFatalMsg:
 
53
        fprintf(stderr, "%s: [FATAL] %s\n", name.constData(), message);
 
54
        abort();
 
55
    }
 
56
}
 
57
 
34
58
static void unity2dGlibHandler(const gchar* domain, GLogLevelFlags level, const gchar* message, gpointer /* user_data */)
35
59
{
36
60
    switch (level & G_LOG_LEVEL_MASK) {
59
83
    }
60
84
}
61
85
 
62
 
void installGlibHandler()
 
86
void installHandlers()
63
87
{
64
88
    g_log_set_default_handler(unity2dGlibHandler, 0);
 
89
    qInstallMsgHandler(unity2dQtHandler);
65
90
}
66
91
 
67
92
} // namespace