From 14eb39cc25737642a4a589c9ccabb265fe8659dd Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Fri, 31 Jul 2009 13:56:46 +0200 Subject: Common stuff moved to common. --- common/logging.cpp | 523 +++++++++++++++++++++++++++++++++++++++++++++++ common/logging.h | 164 +++++++++++++++ common/sconnect.h | 43 ++++ contextd/src/Makefile.am | 10 +- contextd/src/logging.cpp | 523 ----------------------------------------------- contextd/src/logging.h | 165 --------------- contextd/src/sconnect.h | 43 ---- 7 files changed, 734 insertions(+), 737 deletions(-) create mode 100644 common/logging.cpp create mode 100644 common/logging.h create mode 100644 common/sconnect.h delete mode 100644 contextd/src/logging.cpp delete mode 100644 contextd/src/logging.h delete mode 100644 contextd/src/sconnect.h diff --git a/common/logging.cpp b/common/logging.cpp new file mode 100644 index 00000000..86f425ac --- /dev/null +++ b/common/logging.cpp @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2008, 2009 Nokia Corporation. + * + * Contact: Marius Vollmer + * + * 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 +#include +#include +#include + +namespace ContextD { + +/*! + \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++) { + QTextStream::operator<<(QString("#" + features.at(i))); + if (i < features.length() - 1) + QTextStream::operator<<(", "); + } + + 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/common/logging.h b/common/logging.h new file mode 100644 index 00000000..0d47722b --- /dev/null +++ b/common/logging.h @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2008, 2009 Nokia Corporation. + * + * Contact: Marius Vollmer + * + * 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 +#include +#include +#include +#include + +#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 + +namespace ContextD { + +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/common/sconnect.h b/common/sconnect.h new file mode 100644 index 00000000..50c6d79e --- /dev/null +++ b/common/sconnect.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2008, 2009 Nokia Corporation. + * + * Contact: Marius Vollmer + * + * This program 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 program 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 program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef SCONNECT_H +#define SCONNECT_H + +#include +#include + +namespace ContextD { + +inline void sconnect(const QObject *from, const char* fromSignal, + const QObject *to, const char* toSignal) +{ + if (!QObject::connect(from, fromSignal, to, toSignal)) + 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" + "core file with gdb's backtrace to see the location.\n" + " *****************\n"); +} + +} + +#endif diff --git a/contextd/src/Makefile.am b/contextd/src/Makefile.am index e353c2a2..5c0a6756 100644 --- a/contextd/src/Makefile.am +++ b/contextd/src/Makefile.am @@ -1,8 +1,6 @@ bin_PROGRAMS = contextd contextd_SOURCES = contextd.cpp \ provider.h \ - logging.cpp \ - logging.h \ loggingfeatures.h \ halprovider.h \ halprovider.cpp \ @@ -10,7 +8,6 @@ contextd_SOURCES = contextd.cpp \ halmanagerinterface.cpp \ haldeviceinterface.cpp \ haldeviceinterface.h \ - sconnect.h \ lowmemprovider.cpp \ lowmemprovider.h \ boolsysfspooler.h \ @@ -20,8 +17,9 @@ AM_CXXFLAGS = $(QtCore_CFLAGS) $(QtDBus_CFLAGS) LIBS += $(QtCore_LIBS) # library dependency hack for seamless make in contextd -AM_CXXFLAGS += -I$(srcdir)/../../libcontextprovider/src \ - '-DCONTEXT_LOG_MODULE_NAME="contextd"' +AM_CXXFLAGS += -I$(srcdir)/../../common \ + -I$(srcdir)/../../libcontextprovider/src \ + '-DCONTEXT_LOG_MODULE_NAME="contextd"' contextd_LDADD = ../../libcontextprovider/src/libcontextprovider.la ../../libcontextprovider/src/libcontextprovider.la: @@ -30,5 +28,5 @@ contextd_LDADD = ../../libcontextprovider/src/libcontextprovider.la # moccing nodist_contextd_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(contextd_SOURCES)) +QT_TOMOC = $(filter %.h, $(contextd_SOURCES)) ../../common/logging.cpp include $(top_srcdir)/am/qt.am diff --git a/contextd/src/logging.cpp b/contextd/src/logging.cpp deleted file mode 100644 index 86f425ac..00000000 --- a/contextd/src/logging.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (C) 2008, 2009 Nokia Corporation. - * - * Contact: Marius Vollmer - * - * 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 -#include -#include -#include - -namespace ContextD { - -/*! - \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++) { - QTextStream::operator<<(QString("#" + features.at(i))); - if (i < features.length() - 1) - QTextStream::operator<<(", "); - } - - 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/contextd/src/logging.h b/contextd/src/logging.h deleted file mode 100644 index 7b03ee0b..00000000 --- a/contextd/src/logging.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2008, 2009 Nokia Corporation. - * - * Contact: Marius Vollmer - * - * 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 -#include -#include -#include -#include - -#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 - -namespace ContextD { - -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/contextd/src/sconnect.h b/contextd/src/sconnect.h deleted file mode 100644 index 50c6d79e..00000000 --- a/contextd/src/sconnect.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2008, 2009 Nokia Corporation. - * - * Contact: Marius Vollmer - * - * This program 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 program 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 program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef SCONNECT_H -#define SCONNECT_H - -#include -#include - -namespace ContextD { - -inline void sconnect(const QObject *from, const char* fromSignal, - const QObject *to, const char* toSignal) -{ - if (!QObject::connect(from, fromSignal, to, toSignal)) - 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" - "core file with gdb's backtrace to see the location.\n" - " *****************\n"); -} - -} - -#endif -- cgit v1.2.3