summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qloggingcategory.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2013-11-04 16:12:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-07 11:29:30 +0100
commit79b975756a100cc46182c2949e71a683a656bd12 (patch)
tree970215a813cabe11ebe1445a249adfcad721b43f /src/corelib/io/qloggingcategory.cpp
parent0491a7a2984393266e3be48f09b20a8deab9f4c8 (diff)
Revert "Add tracing to logging framework"
The tracing API still misses some real-world exposure. Let's re-do this in dev to have more time. This reverts parts of following commits: 466e0dff4bb686e51d0ab3f905631fcb7dd8bfef 7a47aebe9ed41d6cd9c9bcd45758d4d553668e99 a652bab6a7ebf78b029fea95c2801deb6f4f524a 8f0654ceb878b6c8a08c7f5b790027c26e007c13 4162522edd9d31bd2798ab37f083adff818d886e 32f27b4367c4e042a3f0cda671579494e31c1d69 9ff81bdc1ab4e3d14914192cd63ae625a507fe90 Change-Id: If97340c37b8b3363f597683336a8390d5ff386f1 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/corelib/io/qloggingcategory.cpp')
-rw-r--r--src/corelib/io/qloggingcategory.cpp320
1 files changed, 6 insertions, 314 deletions
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index 8d337ec630..10f7a9bbeb 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -75,10 +75,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory,
\l isCriticalEnabled(), \l isTraceEnabled(), as well as \l isEnabled()
to check whether messages for the given message type should be logged.
- \note The qCDebug(), qCWarning(), qCCritical(), qCTrace() and
- qCTraceGuard() macros prevent arguments from being evaluated if the
- respective message types are not enabled for the category, so explicit
- checking is not needed:
+ \note The qCDebug(), qCWarning(), qCCritical() macros prevent arguments
+ from being evaluated if the respective message types are not enabled for the
+ category, so explicit checking is not needed:
\snippet qloggingcategory/main.cpp 4
@@ -103,14 +102,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory,
\snippet qloggingcategory/main.cpp 3
*/
-typedef QVector<QTracer *> Tracers;
-
-class QLoggingCategoryPrivate
-{
-public:
- Tracers tracers;
-};
-
/*!
Constructs a QLoggingCategory object with the provided \a category name.
The object becomes the local identifier for the category.
@@ -118,15 +109,11 @@ public:
If \a category is \c{0}, the category name is changed to \c "default".
*/
QLoggingCategory::QLoggingCategory(const char *category)
- : d(new QLoggingCategoryPrivate),
+ : d(0),
name(0),
enabledDebug(false),
enabledWarning(true),
- enabledCritical(true),
- enabledTrace(false),
- placeholder1(false),
- placeholder2(false),
- placeholder3(false)
+ enabledCritical(true)
{
bool isDefaultCategory
= (category == 0) || (strcmp(category, qtDefaultCategoryName) == 0);
@@ -151,7 +138,6 @@ QLoggingCategory::~QLoggingCategory()
{
if (QLoggingRegistry *reg = QLoggingRegistry::instance())
reg->unregisterCategory(this);
- delete d;
}
/*!
@@ -194,18 +180,6 @@ QLoggingCategory::~QLoggingCategory()
*/
/*!
- \fn bool QLoggingCategory::isTraceEnabled() const
-
- Returns \c true if the tracers associated with this category should
- receive messages. Returns \c false otherwise.
-
- \note The \l qCTrace() and \l qCTraceGuard() macros already do this check
- before executing any
- code. However, calling this method may be useful to avoid
- expensive generation of data that is only used for debug output.
-*/
-
-/*!
Returns \c true if a message of type \a msgtype for the category should be
shown. Returns \c false otherwise.
*/
@@ -215,7 +189,6 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const
case QtDebugMsg: return enabledDebug;
case QtWarningMsg: return enabledWarning;
case QtCriticalMsg: return enabledCritical;
- case QtTraceMsg: return enabledTrace;
case QtFatalMsg: return true;
}
return false;
@@ -237,7 +210,6 @@ void QLoggingCategory::setEnabled(QtMsgType type, bool enable)
case QtDebugMsg: enabledDebug = enable; break;
case QtWarningMsg: enabledWarning = enable; break;
case QtCriticalMsg: enabledCritical = enable; break;
- case QtTraceMsg: enabledTrace = enable; break;
case QtFatalMsg: break;
}
}
@@ -313,7 +285,7 @@ QLoggingCategory::installFilter(QLoggingCategory::CategoryFilter filter)
where \c <category> is the name of the category, potentially with \c{*} as a
wildcard symbol at the start and/or the end. The optional \c <type> must
- be either \c debug, \c warning, \c critical, or \c trace.
+ be either \c debug, \c warning, or \c critical.
Example:
@@ -395,56 +367,6 @@ void QLoggingCategory::setFilterRules(const QString &rules)
*/
/*!
- \relates QLoggingCategory
- \macro qCTrace(category)
- \since 5.2
-
- Returns an output stream for trace messages in the logging category
- \a category.
-
- The macro expands to code that checks whether
- \l QLoggingCategory::isTraceEnabled() evaluates to \c true.
- If so, the stream arguments are processed and sent to the \l QTracer objects
- registered with the category.
-
- \note Arguments are not processed if trace output for the category is not
- enabled, so do not rely on any side effects.
-
- Example:
-
- \snippet qtracer/ftracer.cpp 6
-
- \sa qCTraceGuard() QTraceGuard
-*/
-
-/*!
- \relates QLoggingCategory
- \macro qCTraceGuard(category)
- \since 5.2
-
- The macro expands to code that creates a guard object with automatic
- storage. The guard constructor checks whether
- \l QLoggingCategory::isTraceEnabled() evaluates to \c true.
- If so, the stream arguments are processed and the \c{start()}
- functions of the \l QTracer objects registered with the \a category are
- called.
-
- The guard destructor also checks whether the category is enabled for
- tracing and if so, the \c{end()}
- functions of the \l QTracer objects registered with the \a category are called.
-
- \note Arguments are always processed, even if trace output for the
- category is disabled. They will, however, in that case not be passed
- to the \c{record()} functions of the registered tracers.
-
- Example:
-
- \snippet qtracer/ftracer.cpp 4
-
- \sa qCTrace() QTracer
-*/
-
-/*!
\macro Q_DECLARE_LOGGING_CATEGORY(name)
\relates QLoggingCategory
\since 5.2
@@ -469,234 +391,4 @@ void QLoggingCategory::setFilterRules(const QString &rules)
This macro must be used outside of a class or method.
*/
-
-/*!
- \class QTracer
- \inmodule QtCore
- \since 5.2
-
- \brief The QTracer class provides an interface for handling
- trace events associated with a logging category.
-
- \c QTracer objects are registered with logging categories.
- Multiple \c QTracer objects
- can be registered with the same category, and the same
- \c QTracer object can be registered with different categories.
-
- If code containing \c qCTrace is executed, and the associated
- logging category is enabled for tracing, all \c QTracer objects
- that are registered with the category are notified.
-
- \c QTracer objects
-*/
-
-/*!
- \fn QTracer::QTracer()
-
- Constructs a tracer object.
-
- Example:
-
- \snippet qtracer/ftracer.cpp 2
-*/
-
-/*!
- \fn QTracer::~QTracer()
-
- Destroys the tracer object.
-*/
-
-/*!
- Registers this tracer for the \a category.
-
- The tracer will later be notified of messages of type
- \c QtTraceMsg, as long as that message type
- is enabled in the category.
-
- Example:
-
- \snippet qtracer/ftracer.cpp 1
- \codeline
- \snippet qtracer/ftracer.cpp 7
-*/
-
-void QTracer::addToCategory(QLoggingCategory &category)
-{
- category.d->tracers.append(this);
-}
-
-/*!
- \fn void QTracer::start()
-
- This function is invoked when a tracing activity starts,
- typically from the constructor of a \c QTraceGuard object
- defined by \c qCTrace() or \c qCTraceGuard().
-
- The base implementation does nothing. \c QTracer subclasses
- are advised to override it if needed.
-
- \sa qCTrace(), qCTraceGuard()
-*/
-
-/*!
- \fn void QTracer::end()
-
- This function is invoked when a tracing activity ends,
- typically from the destructor of a \c QTraceGuard object
- defined by \c qCTrace() or \c qCTraceGuard().
-
- The base implementation does nothing. It is common for
- \c QTracer subclasses to override it to perform flushing
- of collected data.
-
- \sa qCTrace(), qCTraceGuard()
-*/
-
-/*!
- \fn void QTracer::record(int data)
-
- This function is invoked during a tracing activity to
- pass integer \a data to the \c QTracer object.
-
- Example:
-
- \snippet qtracer/ftracer.cpp 3
-*/
-
-/*!
- \fn void QTracer::record(const char *data)
-
- This function is invoked during a tracing activity to
- pass string \a data to the \c QTracer object.
-*/
-
-/*!
- \fn void QTracer::record(const QVariant &data)
-
- This function is invoked during a tracing activity to
- pass abitrary (non-integer, non-string) \a data to
- the \c QTracer object.
-*/
-
-/*!
- \class QTraceGuard
- \since 5.2
- \inmodule QtCore
-
- \brief The QTraceGuard class facilitates notifications to
- \c QTracer objects.
-
- \c QTraceGuard objects are typically implicitly created on the
- stack when using the \c qCTrace or \c qCTraceGuard macros and
- are associated to a \c QLoggingCategory.
-
- The constructor of a \c QTraceGuard objects checks whether
- its associated category is enabled, and if so, informs all
- \c QTracer objects registered with the category that a
- tracing activity starts.
-
- The destructor of a \c QTraceGuard objects checks whether
- its associated category is enabled, and if so, informs all
- \c QTracer objects registered with the category that a
- tracing activity ended.
-
- A \c QTraceGuard object created by \c qCTrace will be destroyed
- at the end of the full expression, a guard created by
- \c qCTraceGuard at the end of the block containing the macro.
-
- During the lifetime of a QTraceGuard object, its \c operator<<()
- can be used to pass additional data to the active tracers.
- The fast path handles only \c int and \c{const char *} data,
- but it is possible to use arbitrary values wrapped in \c QVariants.
-
- \sa QTracer
-*/
-
-/*!
- \fn QTraceGuard::QTraceGuard(QLoggingCategory &category)
- \internal
-
- Constructs a trace guard object relaying to \a category.
-*/
-
-/*!
- \fn QTraceGuard::~QTraceGuard()
- \internal
-
- Destroys the trace guard object.
-*/
-
-/*!
- \internal
-
- Calls \c start() on all registered tracers.
-*/
-
-void QTraceGuard::start()
-{
- const Tracers &tracers = target->d->tracers;
- for (int i = tracers.size(); --i >= 0; )
- tracers.at(i)->start();
-}
-
-/*!
- \internal
-
- Calls \c end() on all registered tracers.
-*/
-
-void QTraceGuard::end()
-{
- const Tracers &tracers = target->d->tracers;
- for (int i = tracers.size(); --i >= 0; )
- tracers.at(i)->end();
-}
-
-
-/*!
- \internal
-
- This function is called for int parameters passed to the
- qCTrace stream.
-*/
-
-QTraceGuard &QTraceGuard::operator<<(int msg)
-{
- const Tracers &tracers = target->d->tracers;
- for (int i = tracers.size(); --i >= 0; )
- tracers.at(i)->record(msg);
- return *this;
-}
-
-/*!
- \internal
-
- This function is called for string parameters passed to the
- qCTrace stream.
-*/
-
-QTraceGuard &QTraceGuard::operator<<(const char *msg)
-{
- const Tracers &tracers = target->d->tracers;
- for (int i = tracers.size(); --i >= 0; )
- tracers.at(i)->record(msg);
- return *this;
-}
-
-
-/*!
- \internal
-
- This function is called for QVariant parameters passed to the
- qCTrace stream.
-*/
-
-QTraceGuard &QTraceGuard::operator<<(const QVariant &msg)
-{
- const Tracers &tracers = target->d->tracers;
- for (int i = tracers.size(); --i >= 0; )
- tracers.at(i)->record(msg);
- return *this;
-}
-
QT_END_NAMESPACE