aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Dominic K <mdk@codethink.co.uk>2009-07-31 17:23:17 +0200
committerMichael Dominic K <mdk@codethink.co.uk>2009-07-31 17:23:17 +0200
commit3402e77d26aec4353701966b33b15f9beaca8137 (patch)
tree3cb5ab760f52b5dd94178de8414d591f27d6b488
parent19bb7e8da13a787c45580a60c549092e40374529 (diff)
Moving subscriber to new common infrastructure.
-rw-r--r--common/sconnect.h4
-rw-r--r--libcontextsubscriber/src/Makefile.am20
-rw-r--r--libcontextsubscriber/src/logging.cpp520
-rw-r--r--libcontextsubscriber/src/logging.h160
-rw-r--r--libcontextsubscriber/unit-tests/cdbreader/Makefile.am2
-rw-r--r--libcontextsubscriber/unit-tests/cdbwriter/Makefile.am2
-rw-r--r--libcontextsubscriber/unit-tests/contextpropertyinfo-cdb-dynamic/Makefile.am3
7 files changed, 19 insertions, 692 deletions
diff --git a/common/sconnect.h b/common/sconnect.h
index ac8d0509..3743e9b2 100644
--- a/common/sconnect.h
+++ b/common/sconnect.h
@@ -26,9 +26,9 @@
#include <QDebug>
inline void sconnect(const QObject *from, const char* fromSignal,
- const QObject *to, const char* toSignal)
+ const QObject *to, const char* toSignal, Qt::ConnectionType type = Qt::AutoConnection)
{
- if (!QObject::connect(from, fromSignal, to, toSignal))
+ if (!QObject::connect(from, fromSignal, to, toSignal, type))
qFatal(" *****************\n"
"Connect returned false, aborting, enable core dumping (ulimit -c unlimited), \n"
"enable debug (qmake CONFIG+=debug), recompile, rerun and then use the\n"
diff --git a/libcontextsubscriber/src/Makefile.am b/libcontextsubscriber/src/Makefile.am
index 04219daa..9ab10992 100644
--- a/libcontextsubscriber/src/Makefile.am
+++ b/libcontextsubscriber/src/Makefile.am
@@ -11,15 +11,23 @@ libcontextsubscriber_la_SOURCES = contextproperty.cpp \
cdbwriter.h cdbwriter.cpp cdbreader.cpp cdbreader.h \
infocdbbackend.cpp infocdbbackend.h dbusnamelistener.h \
dbusnamelistener.cpp handlesignalrouter.cpp \
- handlesignalrouter.h sconnect.h queuedinvoker.cpp \
- queuedinvoker.h logging.h logging.cpp loggingfeatures.h
+ handlesignalrouter.h queuedinvoker.cpp \
+ queuedinvoker.h loggingfeatures.h
includecontextsubscriberdir=$(includedir)/contextsubscriber
includecontextsubscriber_HEADERS = contextproperty.h contextpropertyinfo.h contextregistryinfo.h
-AM_CXXFLAGS = $(QtCore_CFLAGS) $(QtXml_CFLAGS) $(QtDBus_CFLAGS) \
- '-DDEFAULT_CONTEXT_PROVIDERS="@datadir@/contextkit/providers/"' \
- '-DCONTEXT_LOG_MODULE_NAME="libcontextsubscriber"'
-LIBS += $(CDB_LIBS) $(QtCore_LIBS) $(QtXml_LIBS) $(QtDBus_LIBS)
+
+AM_CXXFLAGS = -I$(srcdir)/../../common \
+ $(QtCore_CFLAGS) $(QtXml_CFLAGS) $(QtDBus_CFLAGS) \
+ '-DDEFAULT_CONTEXT_PROVIDERS="@datadir@/contextkit/providers/"' \
+ '-DCONTEXT_LOG_MODULE_NAME="libcontextsubscriber"'
+
+../../common/libcommon.a:
+ $(MAKE) -C ../../common libcommon.a
+
+LIBS += $(CDB_LIBS) $(QtCore_LIBS) $(QtXml_LIBS) $(QtDBus_LIBS) ../../common/libcommon.a
+
+.PHONY: ../../common/libcommon.a
# moccing
nodist_libcontextsubscriber_la_SOURCES = mocs.cpp
diff --git a/libcontextsubscriber/src/logging.cpp b/libcontextsubscriber/src/logging.cpp
deleted file mode 100644
index c6440890..00000000
--- a/libcontextsubscriber/src/logging.cpp
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Nokia Corporation.
- *
- * Contact: Marius Vollmer <marius.vollmer@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include "logging.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <QDateTime>
-#include <QFile>
-
-/*!
- \page Logging
-
- \brief The library (and ContexKit in general) use a simple logging system designed
- to unify the output and make the debugging easier.
-
- \section API
-
- Four types of log messages (presented here in the order of importance) are supported:
- \b Test, \b Debug, \b Warning and \b Critical.
-
- The first one, the \b Test message requires some attention. It's meant to be used
- from tests and unit-tests to log various stages of the test execution. It'll make
- the test output more easily filterable.
-
- The log messages can be used like this:
-
- \code
- contextTest() << "This is some message";
- contextDebug() << "My value is:" << someVariable;
- contextWarning() << "Expecting key:" << something.getKey();
- contextCritical() << 5 << "is bigger than" << 4;
- \endcode
-
- Notice that the logging framework (very much like ie \b qDebug) automatically
- ads whitespace. So:
-
- \code
- contextDebug() << "My value is" << 5 << "and should be 5";
- \endcode
-
- ...will actually print:
-
- \code
- My value is 5 and should be 5
- \endcode
-
- \section compilecontrol Compile-time verbosity control
-
- During the compile time certain defines can be used to turn-off debug messages.
- Those defines are:
-
- \code
- CONTEXT_LOG_HIDE_TEST
- CONTEXT_LOG_HIDE_DEBUG
- CONTEXT_LOG_HIDE_WARNING
- CONTEXT_LOG_HIDE_CRITICAL
- \endcode
-
- A given define makes a respective macro message evaluate to an empty code. To be precise:
- it makes the macro message evaluate to an inline do-nothing class that is optimized by the
- compiler to do nothing.
-
- When ie. \c CONTEXT_LOG_HIDE_DEBUG define is used to turn off \c contextDebug()
- messages, the actual string content of the debug messages is \b not included in the binary
- and during runtime the machine does not spend time evaluating it.
-
- Those compile-time control defines are integrated in the build/configure system.
-
- \section runtimecontrol Run-time verbosity control
-
- During run-time, the amount of debugging can be limited (filtered) but it can't be increased
- (expanded). In other words, if a package was compiled with warnings-only, it's not possible
- to make it show debug messages at runtime. But it is possible to make it criticals-only.
-
- The filtering happens via env variables. The major player is the \c CONTEXT_LOG_VERBOSITY variable
- which can be set to \c TEST, \c DEBUG, \c WARNING and \c CRITICAL. The \c CONTEXT_LOG_VERBOSITY
- specifies the minimal level of the messages shown. Ie. \c CONTEXT_LOG_VERBOSITY set to
- \c WARNING will show only warning and criticals.
-
- The format of the output can be tweaked with \c CONTEXT_LOG_HIDE_TIMESTAMPS and \c CONTEXT_LOG_USE_COLOR.
- The first one makes the messages shorter by skipping the timestamp info. The second one adds a
- little bit of ANSI coloring to the messages.
-
- \c CONTEXT_LOG_SHOW_MODULE will filter-out (kill) all messages \b except the ones coming from the
- specified module. Ie.:
-
- \code
- CONTEXT_LOG_SHOW_MODULE="subscriber" ./some-binary
- \endcode
-
- ...will run \c ./some-binary showing log messages \b only from \c subscriber module.
-
- Lastly, \c CONTEXT_LOG_HIDE_MODULE will hide log messages coming from the specified module.
- All other messages will be show.
-
- \section modules Modules in logging
-
- In previous section we discussed and mentioned modules. For the purpose of logging,
- a module is a piece of code (not neccesarily limited to one binary or shared object) that
- forms one component (feature-wise). Specyfying and naming the modules is used
- to set the origin of the logging messages.
-
- The logging module is set using the \c CONTEXT_LOG_MODULE_NAME define. It should be
- (in most cases) defined in the build system and automatically applied to the whole source code.
- Typically (with autotools) this can be achieved with something similar too:
-
- \code
- ...
- AM_CXXFLAGS = '-DCONTEXT_LOG_MODULE_NAME="libtest"'
- ...
- \endcode
-
- If \c CONTEXT_LOG_MODULE_NAME is undefined, the log messages will be marked as coming from an
- \b "Undefined" module.
-
-
- \section features Featues
-
- It's possible also to assign logging messages to feature groups and control the output
- based on that. Features can be compared to tags - one message can belong to zero or more
- features. To add to a feature to a log message:
-
- \code
- contextDebug() << contextFeature("threads") << "Message goes here" << someVariable;
- contextDebug() << contextFeature("threads") << contextFeature("something") << "Message...";
- \endcode
-
- It doesn't matter where features are added to the message. There is no specific order required.
- The following syntax is supported as well:
-
- \code
- contextDebug() << contextFeature("threads") << "Some message..." << contextFeature("another");
- \endcode
-
- There are two enviornment variables that control the output of messages vs. features: \b
- CONTEXT_LOG_SHOW_FEATURES and \b CONTEXT_LOG_HIDE_FEATURES. Both take a comma-separated
- list of features.
-
- If you specify CONTEXT_LOG_SHOW_FEATURES only messages with given features will be printed to
- the screen. If you specify \b CONTEXT_LOG_HIDE_FEATURES, messages with the specified features
- will be hidden (not displayed). For example:
-
- \code
- CONTEXT_LOG_SHOW_FEATURES="threads,util" ./some-binary
- \endcode
-
- ...will make \b only the messages belonging to "threads" or "util" features displayed.
-
- \code
- CONTEXT_LOG_HIDE_FEATURES="threads,util" ./some-binary
- \endcode
-
- ...will hide all logging messages belonging to "threads" and "util" feature groups.
-
- \section vanilla Vanilla
-
- If the default logging output is too much for you, it's possible to set a CONTEXT_LOG_VANILLA
- enviornment variable. This will simplify the logging output greatly -- no timestamps will be printed,
- no module information will be printed, no line/function/class info will be printed.
-*/
-
-/* ContextFeature */
-
-/*!
- \class ContextFeature
-
- \brief This class represents a "feature" in the logging framework/system.
-
- A feature can be ie. "multithreading", "introspection", "dbus" or anything that makes sense
- in your setup. Using features you can later get more filtered debug output. You most likely
- want to use this class like this:
-
-
- \code
- ...
- contextDebug() << ContextFeature("introspection") << "Message";
- ...
- \endcode
-
- One message can belong to many features or to none.
-*/
-
-/// Constructor for a new feature.\a name is the feature name.
-ContextFeature::ContextFeature(QString name) : featureName(name)
-{
-}
-
-/// Returns the name of the feature.
-QString ContextFeature::getName() const
-{
- return featureName;
-}
-
-/* ContextRealLogger */
-
-/*!
- \class ContextRealLogger
-
- \brief A real logging class.
-
- This is used by the actual macros to print messages.
-*/
-
-bool ContextRealLogger::showTest = true;
-bool ContextRealLogger::showDebug = true;
-bool ContextRealLogger::showWarning = true;
-bool ContextRealLogger::showCritical = true;
-bool ContextRealLogger::hideTimestamps = false;
-bool ContextRealLogger::useColor = false;
-char* ContextRealLogger::showModule = NULL;
-char* ContextRealLogger::hideModule = NULL;
-bool ContextRealLogger::initialized = false;
-bool ContextRealLogger::vanilla = false;
-QStringList ContextRealLogger::showFeatures = QStringList();
-QStringList ContextRealLogger::hideFeatures = QStringList();
-
-/// Initialize the class by checking the enviornment variables and setting
-/// the message output params. The log level is set from \c CONTEXT_LOG_VERBOSITY
-/// and from this env var the showTest, showDebug, showWarning... are set. By default
-/// everything is displayed at runtime. It's also possible to not show timestamps in
-/// messages and spice-up the output with some color.
-void ContextRealLogger::initialize()
-{
- if (getenv("CONTEXT_LOG_HIDE_TIMESTAMPS") != NULL)
- hideTimestamps = true;
-
- if (getenv("CONTEXT_LOG_USE_COLOR") != NULL)
- useColor = true;
-
- // Check feature enablers (showFeatures)
- const char *showFeaturesStr = getenv("CONTEXT_LOG_SHOW_FEATURES");
- if (showFeaturesStr) {
- foreach (QString f, QString(showFeaturesStr).split(','))
- showFeatures << f.trimmed();
- }
-
- // Check feature hide (hideFeatures)
- const char *hideFeaturesStr = getenv("CONTEXT_LOG_HIDE_FEATURES");
- if (hideFeaturesStr) {
- foreach (QString f, QString(hideFeaturesStr).split(','))
- hideFeatures << f.trimmed();
- }
-
- // Show/hide given module
- showModule = getenv("CONTEXT_LOG_SHOW_MODULE");
- hideModule = getenv("CONTEXT_LOG_HIDE_MODULE");
-
- // Vanilla
- if (getenv("CONTEXT_LOG_VANILLA"))
- vanilla = true;
-
- // Check and do verbosity
- const char *verbosity = getenv("CONTEXT_LOG_VERBOSITY");
- if (! verbosity)
- return;
-
- if (strcmp(verbosity, "TEST") == 0) {
- // Do nothing, all left true
- } else if (strcmp(verbosity, "DEBUG") == 0) {
- showTest = false;
- } else if (strcmp(verbosity, "WARNING") == 0) {
- showTest = false;
- showDebug = false;
- } else if (strcmp(verbosity, "CRITICAL") == 0) {
- showTest = false;
- showDebug = false;
- showWarning = false;
- } else if (strcmp(verbosity, "NONE") == 0) {
- showDebug = false;
- showTest = false;
- showDebug = false;
- showWarning = false;
- }
-
- initialized = true;
-}
-
-/// Constructor. Called by the macros. \a func is the function name, \a file is
-/// is the current source file and \a line specifies the line number.
-ContextRealLogger::ContextRealLogger(int type, const char *module, const char *func, const char *file, int line)
- : QTextStream(), msgType(type), moduleName(module)
-{
- if (! initialized) {
- // This is not thread safe, but our initialization depends on
- // non-mutable parts anyways, so we should be ok.
- initialize();
- }
-
- setString(&data);
-
- // Add timestamp
- if (! hideTimestamps && ! vanilla)
- *this << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
-
- // Module name
- if (! vanilla)
- *this << QString("[" + QString(module) + "]");
-
- // Message name
- switch(type) {
- case CONTEXT_LOG_MSG_TYPE_DEBUG:
- if (! vanilla)
- *this << "DEBUG";
- break;
- case CONTEXT_LOG_MSG_TYPE_WARNING:
- *this << ((useColor) ? "\033[103mWARNING\033[0m" : "WARNING");
- break;
- case CONTEXT_LOG_MSG_TYPE_CRITICAL:
- *this << ((useColor) ? "\033[101mCRITICAL\033[0m" : "CRITICAL");
- break;
- case CONTEXT_LOG_MSG_TYPE_TEST:
- *this << "TEST";
- break;
- default:
- *this << "UNKNOWN";
- break;
- }
-
- // File, line and function...
-
- if (! vanilla)
- *this << QString("[" + QString(file) + ":" + QString::number(line) + ":" + QString(func) + "]");
-}
-
-bool ContextRealLogger::shouldPrint()
-{
- // First try to eliminated based on message type...
- if (msgType == CONTEXT_LOG_MSG_TYPE_DEBUG && ! showDebug)
- return false;
- else if (msgType == CONTEXT_LOG_MSG_TYPE_WARNING && ! showWarning)
- return false;
- else if (msgType == CONTEXT_LOG_MSG_TYPE_TEST && ! showTest)
- return false;
- else if (msgType == CONTEXT_LOG_MSG_TYPE_CRITICAL && ! showCritical)
- return false;
-
- // Now try to eliminate based on module name...
- if (showModule && strcmp(showModule, moduleName) != 0)
- return false;
-
- if (hideModule && strcmp(hideModule, moduleName) == 0)
- return false;
-
- // Now try to eliminate by feature name
- foreach(QString feature, features) {
- if (hideFeatures.contains(feature))
- return false;
- }
-
- if (showFeatures.length() > 0) {
- foreach(QString feature, showFeatures) {
- if (features.contains(feature))
- return true;
- else
- return false;
- }
- }
-
- return true;
-}
-
-/// Append (print) all the features, separated with commas and wrapped in brackets.
-void ContextRealLogger::appendFeatures()
-{
- if (features.length() == 0)
- return;
-
- QTextStream::operator<<('[');
- int i;
-
- for (i = 0; i < features.length(); i++) {
- *this << QString ("#" + features.at(i));
- if (i < features.length() - 1)
- *this << ",";
- }
-
- QTextStream::operator<<(']');
-}
-
-/// Operator for appending features.
-ContextRealLogger& ContextRealLogger::operator<< (const ContextFeature &f)
-{
- features << f.getName();
- return *this;
-}
-
-/// Destructor, prints \b end-of-line before going down.
-ContextRealLogger::~ContextRealLogger()
-{
- if (shouldPrint()) {
- appendFeatures();
- QTextStream::operator<<('\n');
- QTextStream(stderr) << data;
- }
-
- setDevice(NULL);
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (QChar v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (signed short v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (unsigned short v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (signed int v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (unsigned int v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (signed long v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (unsigned long v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (float v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (double v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (void *v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (const QString &v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (const char *v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (char v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
diff --git a/libcontextsubscriber/src/logging.h b/libcontextsubscriber/src/logging.h
deleted file mode 100644
index c501e458..00000000
--- a/libcontextsubscriber/src/logging.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Nokia Corporation.
- *
- * Contact: Marius Vollmer <marius.vollmer@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#ifndef LOGGING_H
-#define LOGGING_H
-
-#include <QIODevice>
-#include <QString>
-#include <QStringList>
-#include <QTextStream>
-#include <QBuffer>
-
-#define CONTEXT_LOG_MSG_TYPE_TEST 1
-#define CONTEXT_LOG_MSG_TYPE_DEBUG 2
-#define CONTEXT_LOG_MSG_TYPE_WARNING 3
-#define CONTEXT_LOG_MSG_TYPE_CRITICAL 4
-
-#ifndef CONTEXT_LOG_MODULE_NAME
-#define CONTEXT_LOG_MODULE_NAME "unknown"
-#endif
-
-class ContextFeature
-{
-public:
- ContextFeature(QString name);
- QString getName() const;
-
-private:
- QString featureName;
-};
-
-class ContextRealLogger : public QTextStream
-{
-public:
- ContextRealLogger(int msgType, const char *module, const char *func, const char *file, int line);
- ~ContextRealLogger();
-
- static bool showTest; ///< Test messages enabled at runtime
- static bool showDebug; ///< Debug messages enabled at runtime
- static bool showWarning; ///< Warning messages enabled at runtime
- static bool showCritical; ///< Critical messages enabled at runtime
- static bool initialized; ///< Class initialized/env vars parsed
- static bool hideTimestamps; ///< Don't print timestamps
- static bool useColor; ///< Use simple colors for output (yellow for warnings, red for criticals)
- static char *showModule; ///< Show messages \b only from the specified module
- static char *hideModule; ///< Hide messages from the specified module
- static QStringList showFeatures; ///< Show messages with \b only the specified features
- static QStringList hideFeatures; ///< Hide messages with the specified features
- static bool vanilla; ///< Use vanilla (stripped-down) logging
-
- static void initialize();
-
- ContextRealLogger &operator<< (const ContextFeature&);
-
- virtual ContextRealLogger &operator<< (QChar);
- virtual ContextRealLogger &operator<< (signed short);
- virtual ContextRealLogger &operator<< (unsigned short);
- virtual ContextRealLogger &operator<< (signed int);
- virtual ContextRealLogger &operator<< (unsigned int);
- virtual ContextRealLogger &operator<< (signed long);
- virtual ContextRealLogger &operator<< (unsigned long);
- virtual ContextRealLogger &operator<< (float);
- virtual ContextRealLogger &operator<< (double);
- virtual ContextRealLogger &operator<< (void *);
- virtual ContextRealLogger &operator<< (const QString&);
- virtual ContextRealLogger &operator<< (const char *);
- virtual ContextRealLogger &operator<< (char);
-
-private:
-
- bool shouldPrint();
- void appendFeatures();
-
- int msgType; ///< Type of message we're representing.
- const char* moduleName; ///< The module name.
- QString data; ///< Holds the stream data.
- QStringList features;
-};
-
-/*!
- \class ContextZeroLogger
-
- \brief A fake logging class.
-
- When a certain debug message is disabled at a compile-time the debug macros expand to
- this class. It has all functions declared as \b inline and fundamentally kills all input
- targeted at it. The compiler optimizes the \b inline by not calling the functions at all and
- not storing the strings at all.
-*/
-
-class ContextZeroLogger
-{
-public:
- /// Constructor. Does nothing.
- inline ContextZeroLogger() {}
-
- /* Stubby ops */
- inline ContextZeroLogger &operator<< (QChar) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (char) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (signed short) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (unsigned short) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (signed int) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (unsigned int) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (signed long) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (unsigned long) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (float) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (double) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (const char *) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (const QString&) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (void *) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (const ContextFeature&) { return *this;} ///< Does nothing.
-};
-
-/* Macro defs */
-
-#define contextFeature(name) (ContextFeature(name))
-
-#ifdef CONTEXT_LOG_HIDE_TEST
-#define contextTest() (ContextZeroLogger())
-#else
-#define contextTest() (ContextRealLogger(CONTEXT_LOG_MSG_TYPE_TEST, CONTEXT_LOG_MODULE_NAME, __PRETTY_FUNCTION__, __FILE__, __LINE__))
-#endif
-
-#ifdef CONTEXT_LOG_HIDE_DEBUG
-#define contextDebug() (ContextZeroLogger())
-#else
-#define contextDebug() (ContextRealLogger(CONTEXT_LOG_MSG_TYPE_DEBUG, CONTEXT_LOG_MODULE_NAME, __PRETTY_FUNCTION__, __FILE__, __LINE__))
-#endif
-
-#ifdef CONTEXT_LOG_HIDE_WARNING
-#define contextWarning() (ContextZeroLogger())
-#else
-#define contextWarning() (ContextRealLogger(CONTEXT_LOG_MSG_TYPE_WARNING, CONTEXT_LOG_MODULE_NAME, __PRETTY_FUNCTION__, __FILE__, __LINE__))
-#endif
-
-#ifdef CONTEXT_LOG_HIDE_CRITICAL
-#define contextCritical() (ContextZeroLogger())
-#else
-#define contextCritical() (ContextRealLogger(CONTEXT_LOG_MSG_TYPE_CRITICAL, CONTEXT_LOG_MODULE_NAME, __PRETTY_FUNCTION__, __FILE__, __LINE__))
-#endif
-
-#endif // LOGGING_H
diff --git a/libcontextsubscriber/unit-tests/cdbreader/Makefile.am b/libcontextsubscriber/unit-tests/cdbreader/Makefile.am
index 63a7a095..2cffd560 100644
--- a/libcontextsubscriber/unit-tests/cdbreader/Makefile.am
+++ b/libcontextsubscriber/unit-tests/cdbreader/Makefile.am
@@ -10,7 +10,7 @@ EXTRA_DIST = test.cdb
# tests.am is using +=, so we have to set a value here for these four always
AM_CXXFLAGS = '-I$(srcdir)/../util/'
AM_LDFLAGS = $(CDB_LIBS)
-FROM_SOURCE = cdbreader.cpp cdbreader.h logging.cpp logging.h loggingfeatures.h # copy these files from the real source
+FROM_SOURCE = cdbreader.cpp cdbreader.h loggingfeatures.h # copy these files from the real source
FROM_SOURCE_DIR = $(srcdir)/../../src
LDADD =
include $(top_srcdir)/am/tests.am
diff --git a/libcontextsubscriber/unit-tests/cdbwriter/Makefile.am b/libcontextsubscriber/unit-tests/cdbwriter/Makefile.am
index 471d2b4a..1f960842 100644
--- a/libcontextsubscriber/unit-tests/cdbwriter/Makefile.am
+++ b/libcontextsubscriber/unit-tests/cdbwriter/Makefile.am
@@ -9,7 +9,7 @@ COVERAGE_FILES = cdbwriter.cpp
# tests.am is using +=, so we have to set a value here for these four always
AM_CXXFLAGS = '-I$(srcdir)/../util/'
AM_LDFLAGS = $(CDB_LIBS)
-FROM_SOURCE = cdbwriter.cpp cdbwriter.h logging.h logging.cpp loggingfeatures.h # copy these files from the real source
+FROM_SOURCE = cdbwriter.cpp cdbwriter.h loggingfeatures.h # copy these files from the real source
FROM_SOURCE_DIR = $(srcdir)/../../src
LDADD =
include $(top_srcdir)/am/tests.am
diff --git a/libcontextsubscriber/unit-tests/contextpropertyinfo-cdb-dynamic/Makefile.am b/libcontextsubscriber/unit-tests/contextpropertyinfo-cdb-dynamic/Makefile.am
index 4b3e9443..fe8f9ca7 100644
--- a/libcontextsubscriber/unit-tests/contextpropertyinfo-cdb-dynamic/Makefile.am
+++ b/libcontextsubscriber/unit-tests/contextpropertyinfo-cdb-dynamic/Makefile.am
@@ -20,8 +20,7 @@ FROM_SOURCE = contextregistryinfo.cpp contextpropertyinfo.cpp \
cdbreader.cpp contextregistryinfo.h \
contextpropertyinfo.h infobackend.h infoxmlbackend.h \
infocdbbackend.h infoxmlkeysfinder.h cdbreader.h \
- infokeydata.h sconnect.h logging.h logging.cpp \
- loggingfeatures.h
+ infokeydata.h loggingfeatures.h
FROM_SOURCE_DIR = $(srcdir)/../../src
LDADD =