Browse Source

Logging plugin with QDebug support.

Sascha Zelzer 15 years ago
parent
commit
affeaa7818

+ 1 - 0
CMakeLists.txt

@@ -295,6 +295,7 @@ SET(CTK_PLUGINS
   org.commontk.dah.exampleapp:OFF
   org.commontk.dah.examplehost:OFF
   org.commontk.dah.host:OFF
+  org.commontk.log:OFF
   org.commontk.plugingenerator.core:OFF
   org.commontk.plugingenerator.ui:OFF
   )

+ 37 - 0
Plugins/org.commontk.log/CMakeLists.txt

@@ -0,0 +1,37 @@
+PROJECT(org_commontk_log)
+
+SET(PLUGIN_export_directive "org_commontk_log_EXPORT")
+
+SET(PLUGIN_SRCS
+  ctkLogPlugin.cpp
+  ctkLogQDebug.cpp
+  ctkLogService.cpp
+  ctkLogStream.cpp
+)
+
+# Files which should be processed by Qts moc
+SET(PLUGIN_MOC_SRCS
+  ctkLogPlugin_p.h
+  ctkLogQDebug_p.h
+)
+
+# Qt Designer files which should be processed by Qts uic
+SET(PLUGIN_UI_FORMS
+)
+
+# QRC Files which should be compiled into the plugin
+SET(PLUGIN_resources
+)
+
+#Compute the plugin dependencies
+ctkMacroGetTargetLibraries(PLUGIN_target_libraries)
+
+ctkMacroBuildPlugin(
+  NAME ${PROJECT_NAME}
+  EXPORT_DIRECTIVE ${PLUGIN_export_directive}
+  SRCS ${PLUGIN_SRCS}
+  MOC_SRCS ${PLUGIN_MOC_SRCS}
+  UI_FORMS ${PLUGIN_UI_FORMS}
+  RESOURCES ${PLUGIN_resources}
+  TARGET_LIBRARIES ${PLUGIN_target_libraries}
+)

+ 54 - 0
Plugins/org.commontk.log/ctkLogPlugin.cpp

@@ -0,0 +1,54 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#include "ctkLogPlugin_p.h"
+
+#include "ctkLogQDebug_p.h"
+
+#include <QtPlugin>
+#include <QStringList>
+
+ctkLogPlugin::ctkLogPlugin()
+  : logService(0)
+{
+
+}
+
+void ctkLogPlugin::start(ctkPluginContext* context)
+{
+  logService = new ctkLogQDebug();
+  context->registerService(QStringList("ctkLogService"), logService);
+}
+
+void ctkLogPlugin::stop(ctkPluginContext* context)
+{
+  Q_UNUSED(context)
+  if (logService)
+  {
+    delete logService;
+    logService = 0;
+  }
+}
+
+Q_EXPORT_PLUGIN2(org_commontk_log, ctkLogPlugin)
+
+

+ 49 - 0
Plugins/org.commontk.log/ctkLogPlugin_p.h

@@ -0,0 +1,49 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#ifndef CTKLOGPLUGIN_P_H
+#define CTKLOGPLUGIN_P_H
+
+#include <ctkPluginActivator.h>
+
+class ctkLogQDebug;
+
+class ctkLogPlugin :
+  public QObject, public ctkPluginActivator
+{
+  Q_OBJECT
+  Q_INTERFACES(ctkPluginActivator)
+
+public:
+
+  ctkLogPlugin();
+
+  void start(ctkPluginContext* context);
+  void stop(ctkPluginContext* context);
+
+private:
+
+  ctkLogQDebug* logService;
+
+}; // ctkLogPlugin
+
+#endif // CTKLOGPLUGIN_P_H

+ 108 - 0
Plugins/org.commontk.log/ctkLogQDebug.cpp

@@ -0,0 +1,108 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#include "ctkLogQDebug_p.h"
+
+#include <QDateTime>
+#include <QDebug>
+#include <QStringList>
+
+#include <ctkPluginConstants.h>
+
+ctkLogQDebug::ctkLogQDebug()
+  : logLevel(ctkLogService::LOG_DEBUG)
+{
+}
+
+void ctkLogQDebug::log(int level, const QString& message, const std::exception* exception,
+                       const char* file, const char* function, int line)
+{
+  Q_UNUSED(function)
+
+  QString s = QDateTime::currentDateTime().toString(Qt::ISODate)
+      .append(" - ").append(message);
+  exception ? s.append(" (").append(exception->what()).append(")") : false;
+
+  if (file)
+  {
+    s.append(" [at ").append(file).append(":").append(QString::number(line)).append("]");
+  }
+
+  if (level == ctkLogService::LOG_WARNING)
+  {
+    qWarning() << s;
+  }
+  else if (level == ctkLogService::LOG_ERROR)
+  {
+    qCritical() << s;
+  }
+  else
+  {
+    qDebug() << s;
+  }
+}
+
+void ctkLogQDebug::log(const ctkServiceReference& sr, int level, const QString& message,
+                       const std::exception* exception,
+                       const char* file, const char* function, int line)
+{
+  Q_UNUSED(function)
+
+  QString s = QDateTime::currentDateTime().toString(Qt::ISODate)
+      .append(" - [");
+
+  s.append(sr.getProperty(ctkPluginConstants::SERVICE_ID).toString());
+  s.append(";");
+  QStringList clazzes = sr.getProperty(ctkPluginConstants::OBJECTCLASS).toStringList();
+  int i = 0;
+  foreach (QString clazz, clazzes)
+  {
+    if (i > 0) s.append(",");
+    s.append(clazz);
+  }
+
+  s.append(message);
+  exception ? s.append(" (").append(exception->what()).append(")") : false ;
+
+  if (file)
+  {
+    s.append(" [at ").append(file).append(":").append(QString::number(line)).append("]");
+  }
+
+  if (level == ctkLogService::LOG_WARNING)
+  {
+    qWarning() << s;
+  }
+  else if (level == ctkLogService::LOG_ERROR)
+  {
+    qCritical() << s;
+  }
+  else
+  {
+    qDebug() << s;
+  }
+}
+
+int ctkLogQDebug::getLogLevel() const
+{
+  return logLevel;
+}

+ 52 - 0
Plugins/org.commontk.log/ctkLogQDebug_p.h

@@ -0,0 +1,52 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#ifndef CTKLOGQDEBUG_P_H
+#define CTKLOGQDEBUG_P_H
+
+#include "ctkLogService.h"
+
+#include <QObject>
+
+class ctkLogQDebug : public QObject, public ctkLogService
+{
+
+  Q_OBJECT
+  Q_INTERFACES(ctkLogService)
+
+public:
+
+  ctkLogQDebug();
+
+  void log(int level, const QString& message, const std::exception* exception = 0,
+           const char* file = 0, const char* function = 0, int line = -1);
+  void log(const ctkServiceReference& sr, int level, const QString& message,
+           const std::exception* exception = 0,
+           const char* file = 0, const char* function = 0, int line = -1);
+  int getLogLevel() const;
+
+private:
+
+  int logLevel;
+};
+
+#endif // CTKLOGQDEBUG_P_H

+ 28 - 0
Plugins/org.commontk.log/ctkLogService.cpp

@@ -0,0 +1,28 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#include "ctkLogService.h"
+
+const int ctkLogService::LOG_ERROR = 1;
+const int ctkLogService::LOG_WARNING = 2;
+const int ctkLogService::LOG_INFO = 3;
+const int ctkLogService::LOG_DEBUG = 4;

+ 155 - 0
Plugins/org.commontk.log/ctkLogService.h

@@ -0,0 +1,155 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#ifndef CTKLOGSERVICE_H
+#define CTKLOGSERVICE_H
+
+#include <QString>
+
+#include <stdexcept>
+
+#include "ctkLogStream.h"
+
+/**
+ * Provides methods for plugins to write messages to the log.
+ *
+ * <p>
+ * <code>ctkLogService</code> methods are provided to log messages; optionally with a
+ * <code>ctkServiceReference</code> object or an exception.
+ *
+ * <p>
+ * Plugins must log messages in the Plugin Framework with a severity level
+ * according to the following hierarchy:
+ * <ol>
+ * <li>{@link #LOG_ERROR}
+ * <li>{@link #LOG_WARNING}
+ * <li>{@link #LOG_INFO}
+ * <li>{@link #LOG_DEBUG}
+ * </ol>
+ *
+ * @ThreadSafe
+ */
+class org_commontk_log_EXPORT ctkLogService
+{
+
+public:
+
+  virtual ~ctkLogService() {}
+
+
+  /**
+   * An error message (Value 1).
+   *
+   * <p>
+   * This log entry indicates the plugin or service may not be functional.
+   */
+  static const int LOG_ERROR; // = 1;
+
+  /**
+   * A warning message (Value 2).
+   *
+   * <p>
+   * This log entry indicates a plugin or service is still functioning but may
+   * experience problems in the future because of the warning condition.
+   */
+  static const int LOG_WARNING; // = 2;
+
+  /**
+   * An informational message (Value 3).
+   *
+   * <p>
+   * This log entry may be the result of any change in the plugin or service
+   * and does not indicate a problem.
+   */
+  static const int LOG_INFO; // = 3;
+
+  /**
+   * A debugging message (Value 4).
+   *
+   * <p>
+   * This log entry is used for problem determination and may be irrelevant to
+   * anyone but the plugin developer.
+   */
+  static const int LOG_DEBUG; // = 4;
+
+  /**
+   * Logs a message.
+   *
+   * <p>
+   * The <code>ctkServiceReference</code> field and the <code>Exception</code> field
+   * of the <code>ctkLogEntry</code> object will be set to <code>null</code>.
+   *
+   * @param level The severity of the message. This should be one of the
+   *        defined log levels but may be any integer that is interpreted in a
+   *        user defined way.
+   * @param message Human readable string describing the condition.
+   * @param exception The exception that reflects the condition or <code>null</code>.
+   * @see #LOG_ERROR
+   * @see #LOG_WARNING
+   * @see #LOG_INFO
+   * @see #LOG_DEBUG
+   */
+  virtual void log(int level, const QString& message, const std::exception* exception = 0,
+                   const char* file = 0, const char* function = 0, int line = -1) = 0;
+
+  /**
+   * Logs a message associated with a specific <code>ctkServiceReference</code>
+   * object.
+   *
+   * <p>
+   * The <code>Exception</code> field of the <code>ctkLogEntry</code> will be set to
+   * <code>null</code>.
+   *
+   * @param sr The <code>ctkServiceReference</code> object of the service that this
+   *        message is associated with.
+   * @param level The severity of the message. This should be one of the
+   *        defined log levels but may be any integer that is interpreted in a
+   *        user defined way.
+   * @param message Human readable string describing the condition.
+   * @param exception The exception that reflects the condition or
+   *        <code>null</code>.
+   *
+   * @see #LOG_ERROR
+   * @see #LOG_WARNING
+   * @see #LOG_INFO
+   * @see #LOG_DEBUG
+   */
+  virtual void log(const ctkServiceReference& sr, int level, const QString& message,
+                   const std::exception* exception = 0,
+                   const char* file = 0, const char* function = 0, int line = -1) = 0;
+
+  /**
+   * Get the current log level. The log service discards log entries with a
+   * level that is less severe than the current level. E.g. if the current
+   * log level is LOG_WARNING then the log service will discard all log entries with
+   * level LOG_INFO and LOG_DEBUG.
+   *
+   * @return The lowest severity level that is accepted into the log.
+   */
+  virtual int getLogLevel() const = 0;
+
+};
+
+
+Q_DECLARE_INTERFACE(ctkLogService, "org.commontk.log.ctkLogService")
+
+#endif // CTKLOGSERVICE_H

+ 83 - 0
Plugins/org.commontk.log/ctkLogStream.cpp

@@ -0,0 +1,83 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#include "ctkLogStream.h"
+#include "ctkLogService.h"
+
+ctkLogStream::ctkLogStream(ctkLogService* logService, int level, const std::exception* exc,
+                           const char* file, const char* function, int line)
+  : logged(false), logService(logService), level(level), exc(exc),
+    file(file), function(function), line(line)
+{
+  ts.setString(&msg);
+}
+
+ctkLogStream::ctkLogStream(const ctkLogStream& logStream)
+ : msg(logStream.msg), logged(false),
+   logService(logStream.logService), level(logStream.level),
+   exc(logStream.exc), file(logStream.file), function(logStream.function),
+   line(logStream.line)
+{
+  ts.setString(&msg);
+}
+
+ctkLogStream::~ctkLogStream()
+{
+  if (!logged && logService)
+  {
+    logService->log(level, msg, exc, file, function, line);
+  }
+}
+
+
+ctkLogStreamWithServiceRef::ctkLogStreamWithServiceRef(ctkLogService* logService, const ctkServiceReference& sr,
+                                                       int level, const std::exception* exc, const char* file,
+                                                       const char* function, int line)
+  : ctkLogStream(logService, level, exc, file, function, line), sr(sr)
+{
+
+}
+
+ctkLogStreamWithServiceRef::ctkLogStreamWithServiceRef(const ctkLogStreamWithServiceRef &logStreamWithRef)
+ : ctkLogStream(logStreamWithRef), sr(logStreamWithRef.sr)
+{
+
+}
+
+ctkLogStreamWithServiceRef::~ctkLogStreamWithServiceRef()
+{
+  if (!logged)
+  {
+    logService->log(sr, level, msg, exc, file, function, line);
+    logged = true;
+  }
+}
+
+
+ctkNullLogStream::ctkNullLogStream() : ctkLogStream(0, 0)
+{}
+
+ctkNullLogStream::~ctkNullLogStream()
+{
+  logged = true;
+}
+

+ 118 - 0
Plugins/org.commontk.log/ctkLogStream.h

@@ -0,0 +1,118 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#ifndef CTKLOGSTREAM_H
+#define CTKLOGSTREAM_H
+
+#include <org_commontk_log_Export.h>
+
+#include <ctkServiceReference.h>
+#include <QTextStream>
+
+class ctkLogService;
+
+class org_commontk_log_EXPORT ctkLogStream
+{
+public:
+
+  ctkLogStream(ctkLogService* logService, int level, const std::exception* exc = 0,
+               const char* file = 0, const char* function = 0, int line = -1);
+  ctkLogStream(const ctkLogStream& logStream);
+
+  virtual ~ctkLogStream();
+
+  template<class T>
+  ctkLogStream& operator <<(const T& t)
+  {
+    ts << t;
+    return *this;
+  }
+
+  ctkLogStream& operator <<(const char* c)
+  {
+    ts << c;
+    return *this;
+  }
+
+protected:
+
+  QString msg;
+  QTextStream ts;
+  bool logged;
+
+  ctkLogService* logService;
+  int level;
+  const std::exception* exc;
+
+  const char* file;
+  const char* function;
+  const int line;
+};
+
+class org_commontk_log_EXPORT ctkLogStreamWithServiceRef : public ctkLogStream
+{
+public:
+
+  ctkLogStreamWithServiceRef(ctkLogService* logService, const ctkServiceReference& sr,
+                             int level, const std::exception* exc = 0,
+                             const char* file = 0, const char* function = 0, int line = -1);
+  ctkLogStreamWithServiceRef(const ctkLogStreamWithServiceRef& logStreamWithRef);
+
+  ~ctkLogStreamWithServiceRef();
+
+protected:
+
+  ctkServiceReference sr;
+};
+
+class org_commontk_log_EXPORT ctkNullLogStream : public ctkLogStream
+{
+public:
+
+  ctkNullLogStream();
+  ~ctkNullLogStream();
+
+};
+
+
+#define CTK_DEBUG(logService) ((logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? ctkLogStream(logService, ctkLogService::LOG_DEBUG, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream())
+#define CTK_DEBUG_EXC(logService, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? ctkLogStream(logService, ctkLogService::LOG_DEBUG, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_DEBUG_SR(logService, serviceRef) (logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_DEBUG, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_DEBUG_SR_EXC(logService, serviceRef, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_DEBUG, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+
+#define CTK_INFO(logService) (logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? ctkLogStream(logService, ctkLogService::LOG_INFO, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_INFO_EXC(logService, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? ctkLogStream(logService, ctkLogService::LOG_INFO, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_INFO_SR(logService, serviceRef) (logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_INFO, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_INFO_SR_EXC(logService, serviceRef, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_INFO, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+
+#define CTK_WARN(logService) (logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? ctkLogStream(logService, ctkLogService::LOG_WARNING, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_WARN_EXC(logService, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? ctkLogStream(logService, ctkLogService::LOG_WARNING, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_WARN_SR(logService, serviceRef) (logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_WARNING, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_WARN_SR_EXC(logService, serviceRef, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_WARNING, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+
+#define CTK_ERROR(logService) (logService && logService->getLogLevel() >= ctkLogService::LOG_ERROR) ? ctkLogStream(logService, ctkLogService::LOG_ERROR, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_ERROR_EXC(logService, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_ERROR) ? ctkLogStream(logService, ctkLogService::LOG_ERROR, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_ERROR_SR(logService, serviceRef) (logService && logService->getLogLevel() >= ctkLogService::LOG_ERRO) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_ERROR, 0, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+#define CTK_ERROR_SR_EXC(logService, serviceRef, exc) (logService && logService->getLogLevel() >= ctkLogService::LOG_ERROR) ? ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_ERROR, exc, __FILE__, __FUNCTION__, __LINE__) : ctkNullLogStream()
+
+
+#endif // CTKLOGSTREAM_H

+ 2 - 0
Plugins/org.commontk.log/manifest_headers.cmake

@@ -0,0 +1,2 @@
+SET(Plugin-Name "Log Service")
+SET(Plugin-ActivationPolicy "eager")

+ 9 - 0
Plugins/org.commontk.log/target_libraries.cmake

@@ -0,0 +1,9 @@
+# See CMake/ctkMacroGetTargetLibraries.cmake
+#
+# This file should list the libraries required to build the current CTK plugin.
+# For specifying required plugins, see the manifest_headers.cmake file.
+#
+
+SET(target_libraries
+  CTKPluginFramework
+)