OSDN Git Service

84c2cf67924f3b4e978df8f01c409f5a9d90f2cc
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / logger / logger.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef QLOGGER_H
35 #define QLOGGER_H
36
37 #include <QString>
38 #include <QStringList>
39
40
41 #define qLogger(str) qDebug() << QString("GLOBAL %1, %2").arg(__FUNC__).arg(#str);
42 #define qLogger(module, str) qDebug() << QString("%1, %2 %3").arg(__FUNC__).arg(#str).arg(#module);
43
44 class QFile;
45 class QTime;
46
47 class QLogger {
48 public:
49     static void enable() {
50         setEnabled(true);
51     }
52     static void disable() {
53         setEnabled(false);
54     }
55     static void setLevel(int level);
56     static void setModul(const QString &module);
57     static void setFilename(const QString &filename);
58     static void setEnabled(bool enabled);
59     static void setFlush(int msec);
60     static void flush();
61     static void setSilent(bool silent);
62     ~QLogger();
63
64 private:
65     QLogger();
66
67     static QLogger* instance();
68     static QLogger* m_instance;
69     void output(const char *msg);
70     static void loggerMessageOutput(QtMsgType type, const char *msg);
71
72     int m_level;
73     QString m_modul;
74     QString m_fileName;
75     QFile* m_file;
76     bool m_enabled;
77     bool m_silent;
78     int m_flushTime;
79     int m_lastFlush;
80     QStringList m_buffer;
81     QTime *m_timer;
82
83 };
84
85 #endif // QLOGGER_H