Commit 61276ab6 authored by hjk's avatar hjk

Remove logging wrapper code for Qt 4 compatibility

Change-Id: I95ed943638895b718862f05e3f706dcbef4c6a7d
Reviewed-by: default avatarUlf Hermann <ulf.hermann@digia.com>
parent 251a1d25
......@@ -36,12 +36,12 @@
#include <extensionsystem/pluginspec.h>
#include <qtsingleapplication.h>
#include <utils/hostosinfo.h>
#include <utils/logging.h>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QLibraryInfo>
#include <QLoggingCategory>
#include <QSettings>
#include <QTextStream>
#include <QThreadPool>
......
......@@ -29,15 +29,12 @@
#include "qmljscodeformatter.h"
#include <utils/logging.h>
#include <QLoggingCategory>
#include <QMetaEnum>
#include <QTextDocument>
#include <QTextBlock>
#include <QTextDocument>
namespace {
Q_LOGGING_CATEGORY(formatterLog, "qtc.qmljs.formatter")
}
static Q_LOGGING_CATEGORY(formatterLog, "qtc.qmljs.formatter")
namespace QmlJS {
......
......@@ -29,9 +29,10 @@
#ifndef QMLJSCONSTANTS_H
#define QMLJSCONSTANTS_H
#include "qmljs_global.h"
#include <utils/logging.h>
#include <QLoggingCategory>
namespace QmlJS {
......
......@@ -29,11 +29,10 @@
#include "qmljsicons.h"
#include <utils/logging.h>
#include <QIcon>
#include <QDir>
#include <QHash>
#include <QIcon>
#include <QLoggingCategory>
#include <QPair>
using namespace QmlJS;
......@@ -43,9 +42,7 @@ enum {
debug = false
};
namespace {
Q_LOGGING_CATEGORY(iconsLog, "qtc.qmljs.icons")
}
static Q_LOGGING_CATEGORY(iconsLog, "qtc.qmljs.icons")
namespace QmlJS {
......
......@@ -32,15 +32,13 @@
#include "qmljsqrcparser.h"
#include <utils/qtcassert.h>
#include <utils/logging.h>
#include <QCryptographicHash>
#include <QLoggingCategory>
#include <algorithm>
namespace {
Q_LOGGING_CATEGORY(importsLog, "qtc.qmljs.imports")
}
static Q_LOGGING_CATEGORY(importsLog, "qtc.qmljs.imports")
namespace QmlJS {
......
......@@ -33,15 +33,12 @@
#include "parser/qmljslexer_p.h"
#include "parser/qmljsengine_p.h"
#include <utils/logging.h>
#include "qmljsutils.h"
#include <QFile>
#include <QLoggingCategory>
namespace {
Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader")
}
static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader")
namespace QmlJS{
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef LOGGING_H
#define LOGGING_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
#include <QDebug>
//
// Qt < 5.2 didn't feature categorized logging:
// Just enable qCWarning, qCCritical, but disable qCDebug
//
class QLoggingCategory
{
Q_DISABLE_COPY(QLoggingCategory)
public:
explicit QLoggingCategory(const char *category) : name(category) {}
~QLoggingCategory() {}
static void setFilterRules(const QString &) {}
bool isDebugEnabled() const { return false; }
bool isWarningEnabled() const { return true; }
bool isCriticalEnabled() const { return true; }
const char *categoryName() const { return name; }
QLoggingCategory &operator()() { return *this; }
private:
const char *name;
};
#define Q_DECLARE_LOGGING_CATEGORY(name) \
extern QLoggingCategory &name();
// relies on QLoggingCategory(QString) being thread safe!
#define Q_LOGGING_CATEGORY(name, string) \
QLoggingCategory &name() \
{ \
static QLoggingCategory category(string); \
return category; \
}
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
//
// Qt 5.0, 5.1 do have already support for categories in QMessageLogger
//
#define qCDebug(category, ...) \
for (bool q_category_enabled = category().isDebugEnabled(); q_category_enabled; q_category_enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug(__VA_ARGS__)
#define qCWarning(category, ...) \
for (bool q_category_enabled = category().isWarningEnabled(); q_category_enabled; q_category_enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).warning(__VA_ARGS__)
#define qCCritical(category, ...) \
for (bool q_category_enabled = category().isCriticalEnabled(); q_category_enabled; q_category_enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_QT_VERSION < 0x053000INFO, category().categoryName()).critical(__VA_ARGS__)
# else
//
// Qt 4: just map to qDebug etc
//
#define qCDebug(category, ...) \
for (bool q_category_enabled = category().isDebugEnabled(); q_category_enabled; q_category_enabled = false) \
qDebug(__VA_ARGS__)
#define qCWarning(category, ...) \
for (bool q_category_enabled = category().isWarningEnabled(); q_category_enabled; q_category_enabled = false) \
qWarning(__VA_ARGS__)
#define qCCritical(category, ...) \
for (bool q_category_enabled = category().isCriticalEnabled(); q_category_enabled; q_category_enabled = false) \
qCritical(__VA_ARGS__)
# endif // QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
#else // QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#include <QLoggingCategory>
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
// printf style for qCDebug was only added in Qt 5.3
#undef qCDebug
#undef qCWarning
#undef qCCritical
#define qCDebug(category, ...) \
for (bool q_category_enabled = category().isDebugEnabled(); q_category_enabled; q_category_enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug(__VA_ARGS__)
#define qCWarning(category, ...) \
for (bool q_category_enabled = category().isWarningEnabled(); q_category_enabled; q_category_enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).warning(__VA_ARGS__)
#define qCCritical(category, ...) \
for (bool q_category_enabled = category().isCriticalEnabled(); q_category_enabled; q_category_enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical(__VA_ARGS__)
#endif // QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
#endif // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
#endif // LOGGING_H
......@@ -180,7 +180,6 @@ HEADERS += \
$$PWD/ansiescapecodehandler.h \
$$PWD/execmenu.h \
$$PWD/completinglineedit.h \
$$PWD/logging.h \
$$PWD/winutils.h \
$$PWD/itemviews.h \
$$PWD/treeviewcombobox.h \
......
......@@ -107,7 +107,6 @@ QtcLibrary {
"linecolumnlabel.cpp",
"linecolumnlabel.h",
"listutils.h",
"logging.h",
"multitask.h",
"navigationtreeview.cpp",
"navigationtreeview.h",
......
......@@ -36,11 +36,12 @@
#include <debugger/watchhandler.h>
#include <qmldebug/qmldebugconstants.h>
#include <utils/logging.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
#include <QElapsedTimer>
#include <QFileInfo>
#include <QLoggingCategory>
using namespace QmlDebug;
using namespace QmlDebug::Constants;
......
......@@ -30,7 +30,7 @@
#define IOSCONSTANTS_H
#include <QtGlobal>
#include <utils/logging.h>
#include <QLoggingCategory>
namespace Ios {
namespace Internal {
......
......@@ -29,16 +29,14 @@
#include "iosprobe.h"
#include <utils/logging.h>
#include <QFileInfo>
#include <QProcess>
#include <QDir>
#include <QFileInfo>
#include <QFileInfoList>
#include <QLoggingCategory>
#include <QProcess>
static Q_LOGGING_CATEGORY(probeLog, "qtc.ios.probe")
namespace {
Q_LOGGING_CATEGORY(probeLog, "qtc.ios.probe")
}
namespace Ios {
static QString qsystem(const QString &exe, const QStringList &args = QStringList())
......
......@@ -34,24 +34,22 @@
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <utils/logging.h>
#include <QProcess>
#include <QXmlStreamReader>
#include <QSocketNotifier>
#include <QCoreApplication>
#include <QFileInfo>
#include <QList>
#include <QScopedArrayPointer>
#include <QLoggingCategory>
#include <QProcess>
#include <QProcessEnvironment>
#include <QFileInfo>
#include <QScopedArrayPointer>
#include <QSocketNotifier>
#include <QTimer>
#include <QXmlStreamReader>
#include <string.h>
#include <errno.h>
namespace {
Q_LOGGING_CATEGORY(toolHandlerLog, "qtc.ios.toolhandler")
}
static Q_LOGGING_CATEGORY(toolHandlerLog, "qtc.ios.toolhandler")
namespace Ios {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment