http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_listener.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_listener.h 
b/log_service/public/include/log_listener.h
deleted file mode 100644
index b726994..0000000
--- a/log_service/public/include/log_listener.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_listener.h
- *
- *  \date       Jul 4, 2011
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-
-#ifndef LOG_LISTENER_H_
-#define LOG_LISTENER_H_
-
-#include "log_entry.h"
-#include "celix_errno.h"
-
-struct log_listener {
-    void *handle;
-    celix_status_t (*logged)(struct log_listener *listener, log_entry_pt 
entry);
-};
-
-typedef struct log_listener log_listener_t;
-typedef log_listener_t* log_listener_pt;
-
-celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt 
entry);
-
-#endif /* LOG_LISTENER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_reader_service.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_reader_service.h 
b/log_service/public/include/log_reader_service.h
deleted file mode 100644
index 6815123..0000000
--- a/log_service/public/include/log_reader_service.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_reader_service.h
- *
- *  \date       Jun 26, 2011
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-
-#ifndef LOG_READER_SERVICE_H_
-#define LOG_READER_SERVICE_H_
-
-
-#include "celix_errno.h"
-#include "linked_list.h"
-#include "log_listener.h"
-
-static const char * const OSGI_LOGSERVICE_READER_SERVICE_NAME = 
"log_reader_service";
-
-typedef struct log_reader_data log_reader_data_t;
-typedef log_reader_data_t* log_reader_data_pt;
-
-struct log_reader_service {
-    log_reader_data_pt reader;
-    celix_status_t (*getLog)(log_reader_data_pt reader, linked_list_pt *list);
-    celix_status_t (*addLogListener)(log_reader_data_pt reader, 
log_listener_pt listener);
-    celix_status_t (*removeLogListener)(log_reader_data_pt reader, 
log_listener_pt listener);
-    celix_status_t (*removeAllLogListener)(log_reader_data_pt reader);
-};
-
-typedef struct log_reader_service * log_reader_service_pt;
-
-#endif /* LOG_READER_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/include/log_service.h
----------------------------------------------------------------------
diff --git a/log_service/public/include/log_service.h 
b/log_service/public/include/log_service.h
deleted file mode 100644
index 2691e35..0000000
--- a/log_service/public/include/log_service.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_service.h
- *
- *  \date       Jun 22, 2011
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-
-#ifndef LOG_SERVICE_H_
-#define LOG_SERVICE_H_
-
-#include "celix_errno.h"
-#include "service_reference.h"
-
-static const char * const OSGI_LOGSERVICE_NAME = "log_service";
-
-typedef struct log_service_data *log_service_data_pt;
-
-enum log_level
-{
-    OSGI_LOGSERVICE_ERROR = 0x00000001,
-    OSGI_LOGSERVICE_WARNING = 0x00000002,
-    OSGI_LOGSERVICE_INFO = 0x00000003,
-    OSGI_LOGSERVICE_DEBUG = 0x00000004,
-};
-
-typedef enum log_level log_level_t;
-
-struct log_service {
-    log_service_data_pt logger;
-    celix_status_t (*log)(log_service_data_pt logger, log_level_t level, char 
* message);
-    celix_status_t (*logSr)(log_service_data_pt logger, service_reference_pt 
reference, log_level_t level, char * message);
-};
-
-typedef struct log_service log_service_t;
-typedef log_service_t* log_service_pt;
-
-
-
-#endif /* LOG_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/public/src/log_helper.c
----------------------------------------------------------------------
diff --git a/log_service/public/src/log_helper.c 
b/log_service/public/src/log_helper.c
deleted file mode 100644
index c0cd309..0000000
--- a/log_service/public/src/log_helper.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_helper.c
- *
- *  \date       Nov 10, 2014
- *  \author     <a href="mailto:[email protected]";>Apache Celix Project 
Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "bundle_context.h"
-#include "service_tracker.h"
-#include "celix_threads.h"
-#include "array_list.h"
-
-#include "celix_errno.h"
-#include "log_service.h"
-
-#include "log_helper.h"
-
-#define LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME         
"LOGHELPER_ENABLE_STDOUT_FALLBACK"
-
-
-struct log_helper {
-       bundle_context_pt bundleContext;
-    service_tracker_pt logServiceTracker;
-       celix_thread_mutex_t logListLock;
-       array_list_pt logServices;
-       bool stdOutFallback;
-};
-
-celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt 
reference, void *service);
-celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt 
reference, void *service);
-
-
-celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* 
loghelper)
-{
-       celix_status_t status = CELIX_SUCCESS;
-
-       (*loghelper) = calloc(1, sizeof(**loghelper));
-
-       if (!(*loghelper))
-       {
-               status = CELIX_ENOMEM;
-       }
-       else
-       {
-               const char* stdOutFallbackStr = NULL;
-               (*loghelper)->bundleContext = context;
-               (*loghelper)->logServiceTracker = NULL;
-               (*loghelper)->stdOutFallback = false;
-
-               bundleContext_getProperty(context, 
LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME, &stdOutFallbackStr);
-
-               if (stdOutFallbackStr != NULL) {
-                       (*loghelper)->stdOutFallback = true;
-               }
-
-               pthread_mutex_init(&(*loghelper)->logListLock, NULL);
-        arrayList_create(&(*loghelper)->logServices);
-       }
-
-       return status;
-}
-
-celix_status_t logHelper_start(log_helper_pt loghelper)
-{
-       celix_status_t status;
-       service_tracker_customizer_pt logTrackerCustomizer = NULL;
-
-       status = serviceTrackerCustomizer_create(loghelper, NULL, 
logHelper_logServiceAdded, NULL, logHelper_logServiceRemoved, 
&logTrackerCustomizer);
-
-       if (status == CELIX_SUCCESS) {
-        loghelper->logServiceTracker = NULL;
-               status = serviceTracker_create(loghelper->bundleContext, 
(char*) OSGI_LOGSERVICE_NAME, logTrackerCustomizer, 
&loghelper->logServiceTracker);
-       }
-
-       if (status == CELIX_SUCCESS) {
-               status = serviceTracker_open(loghelper->logServiceTracker);
-       }
-
-       return status;
-}
-
-
-
-celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt 
reference, void *service)
-{
-       log_helper_pt loghelper = handle;
-
-       pthread_mutex_lock(&loghelper->logListLock);
-       arrayList_add(loghelper->logServices, service);
-       pthread_mutex_unlock(&loghelper->logListLock);
-
-       return CELIX_SUCCESS;
-}
-
-celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt 
reference, void *service)
-{
-       log_helper_pt loghelper = handle;
-
-       pthread_mutex_lock(&loghelper->logListLock);
-       arrayList_removeElement(loghelper->logServices, service);
-       pthread_mutex_unlock(&loghelper->logListLock);
-
-       return CELIX_SUCCESS;
-}
-
-
-celix_status_t logHelper_stop(log_helper_pt loghelper) {
-       celix_status_t status;
-
-    status = serviceTracker_close(loghelper->logServiceTracker);
-
-    return status;
-}
-
-celix_status_t logHelper_destroy(log_helper_pt* loghelper) {
-        celix_status_t status = CELIX_SUCCESS;
-
-        if((*loghelper)->logServiceTracker){
-               serviceTracker_destroy((*loghelper)->logServiceTracker);
-        }
-
-        pthread_mutex_lock(&(*loghelper)->logListLock);
-        arrayList_destroy((*loghelper)->logServices);
-       pthread_mutex_unlock(&(*loghelper)->logListLock);
-
-        pthread_mutex_destroy(&(*loghelper)->logListLock);
-
-        free(*loghelper);
-        *loghelper = NULL;
-        return status;
-}
-
-
-
-
-celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* 
message, ... )
-{
-    celix_status_t status = CELIX_SUCCESS;
-       va_list listPointer;
-    char msg[1024];
-    msg[0] = '\0';
-    bool logged = false;
-
-    if(loghelper == NULL){
-       return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-       va_start(listPointer, message);
-       vsnprintf(msg, 1024, message, listPointer);
-
-       pthread_mutex_lock(&loghelper->logListLock);
-
-       int i = 0;
-       for (; i < arrayList_size(loghelper->logServices); i++) {
-               log_service_pt logService = 
arrayList_get(loghelper->logServices, i);
-               if (logService != NULL) {
-                       (logService->log)(logService->logger, level, msg);
-                       logged = true;
-               }
-       }
-
-       pthread_mutex_unlock(&loghelper->logListLock);
-
-    if (!logged && loghelper->stdOutFallback) {
-        char *levelStr = NULL;
-
-        switch (level) {
-            case OSGI_LOGSERVICE_ERROR:
-                levelStr = "ERROR";
-                break;
-            case OSGI_LOGSERVICE_WARNING:
-                levelStr = "WARNING";
-                break;
-            case OSGI_LOGSERVICE_INFO:
-                levelStr = "INFO";
-                break;
-            case OSGI_LOGSERVICE_DEBUG:
-            default:
-                levelStr = "DEBUG";
-                break;
-        }
-
-        printf("%s: %s\n", levelStr, msg);
-    }
-
-    va_end(listPointer);
-
-       return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log.c
----------------------------------------------------------------------
diff --git a/log_service/src/log.c b/log_service/src/log.c
new file mode 100644
index 0000000..5b29318
--- /dev/null
+++ b/log_service/src/log.c
@@ -0,0 +1,375 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "log.h"
+#include "linked_list_iterator.h"
+#include "array_list.h"
+
+struct log {
+       linked_list_pt entries;
+       celix_thread_mutex_t lock;
+
+       array_list_pt listeners;
+       array_list_pt listenerEntries;
+
+       celix_thread_t listenerThread;
+       bool running;
+
+       celix_thread_cond_t entriesToDeliver;
+       celix_thread_mutex_t deliverLock;
+       celix_thread_mutex_t listenerLock;
+
+       int max_size;
+       bool store_debug;
+};
+
+static celix_status_t log_startListenerThread(log_pt logger);
+static celix_status_t log_stopListenerThread(log_pt logger);
+
+
+static void *log_listenerThread(void *data);
+
+celix_status_t log_create(int max_size, bool store_debug, log_pt *logger) {
+       celix_status_t status = CELIX_ENOMEM;
+
+       *logger = calloc(1, sizeof(**logger));
+
+       if (*logger != NULL) {
+               linkedList_create(&(*logger)->entries);
+
+               status = celixThreadMutex_create(&(*logger)->lock, NULL);
+
+               (*logger)->listeners = NULL;
+               (*logger)->listenerEntries = NULL;
+               (*logger)->listenerThread = celix_thread_default;
+               (*logger)->running = false;
+
+               (*logger)->max_size = max_size;
+               (*logger)->store_debug = store_debug;
+
+               arrayList_create(&(*logger)->listeners);
+               arrayList_create(&(*logger)->listenerEntries);
+
+               if (celixThreadCondition_init(&(*logger)->entriesToDeliver, 
NULL) != CELIX_SUCCESS) {
+                       status = CELIX_INVALID_SYNTAX;
+               }
+               else if (celixThreadMutex_create(&(*logger)->deliverLock, NULL) 
!= CELIX_SUCCESS) {
+                       status = CELIX_INVALID_SYNTAX;
+               }
+               else if (celixThreadMutex_create(&(*logger)->listenerLock, 
NULL) != CELIX_SUCCESS) {
+                       status = CELIX_INVALID_SYNTAX;
+               }
+               else {
+                       status = CELIX_SUCCESS;
+               }
+       }
+
+       return status;
+}
+
+celix_status_t log_destroy(log_pt logger) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       celixThreadMutex_destroy(&logger->listenerLock);
+       celixThreadMutex_destroy(&logger->deliverLock);
+       celixThreadCondition_destroy(&logger->entriesToDeliver);
+
+       arrayList_destroy(logger->listeners);
+       linked_list_iterator_pt iter = 
linkedListIterator_create(logger->entries, 0);
+       while (linkedListIterator_hasNext(iter)) {
+               log_entry_pt entry = linkedListIterator_next(iter);
+               if (arrayList_contains(logger->listenerEntries, entry)) {
+                       arrayList_removeElement(logger->listenerEntries, entry);
+               }
+               logEntry_destroy(&entry);
+       }
+       linkedListIterator_destroy(iter);
+
+       array_list_iterator_pt entryIter = 
arrayListIterator_create(logger->listenerEntries);
+
+       while (arrayListIterator_hasNext(entryIter)) {
+               log_entry_pt entry = arrayListIterator_next(entryIter);
+               logEntry_destroy(&entry);
+       }
+       arrayListIterator_destroy(entryIter);
+
+       arrayList_destroy(logger->listenerEntries);
+       linkedList_destroy(logger->entries);
+
+       celixThreadMutex_destroy(&logger->lock);
+
+       free(logger);
+
+       return status;
+}
+
+celix_status_t log_addEntry(log_pt log, log_entry_pt entry) {
+       celixThreadMutex_lock(&log->lock);
+
+       if (log->max_size != 0) {
+               if (log->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG) {
+                       linkedList_addElement(log->entries, entry);
+               }
+       }
+
+       celixThreadMutex_lock(&log->deliverLock);
+       arrayList_add(log->listenerEntries, entry);
+       celixThreadMutex_unlock(&log->deliverLock);
+
+       celixThreadCondition_signal(&log->entriesToDeliver);
+
+       if (log->max_size != 0) {
+               if (log->max_size != -1) {
+                       if (linkedList_size(log->entries) > log->max_size) {
+                               log_entry_pt rentry = 
linkedList_removeFirst(log->entries);
+                               if (rentry) {
+                                       
celixThreadMutex_lock(&log->deliverLock);
+                                       
arrayList_removeElement(log->listenerEntries, rentry);
+                                       logEntry_destroy(&rentry);
+                                       
celixThreadMutex_unlock(&log->deliverLock);
+                               }
+                       }
+               }
+       }
+
+       celixThreadMutex_unlock(&log->lock);
+
+       return CELIX_SUCCESS;
+}
+
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list) {
+       linked_list_pt entries = NULL;
+       if (linkedList_create(&entries) == CELIX_SUCCESS) {
+               linked_list_iterator_pt iter = NULL;
+
+               celixThreadMutex_lock(&log->lock);
+
+               iter = linkedListIterator_create(log->entries, 0);
+               while (linkedListIterator_hasNext(iter)) {
+                       linkedList_addElement(entries, 
linkedListIterator_next(iter));
+               }
+               linkedListIterator_destroy(iter);
+
+               *list = entries;
+
+               celixThreadMutex_unlock(&log->lock);
+
+               return CELIX_SUCCESS;
+       } else {
+               return CELIX_ENOMEM;
+       }
+}
+
+celix_status_t log_bundleChanged(void *listener, bundle_event_pt event) {
+       celix_status_t status = CELIX_SUCCESS;
+       log_pt logger = ((bundle_listener_pt) listener)->handle;
+       log_entry_pt entry = NULL;
+
+       int messagesLength = 10;
+       char *messages[] = {
+               "BUNDLE_EVENT_INSTALLED",
+               "BUNDLE_EVENT_STARTED",
+               "BUNDLE_EVENT_STOPPED",
+               "BUNDLE_EVENT_UPDATED",
+               "BUNDLE_EVENT_UNINSTALLED",
+               "BUNDLE_EVENT_RESOLVED",
+               "BUNDLE_EVENT_UNRESOLVED",
+               "BUNDLE_EVENT_STARTING",
+               "BUNDLE_EVENT_STOPPING",
+               "BUNDLE_EVENT_LAZY_ACTIVATION"
+       };
+
+       char *message = NULL;
+       int i = 0;
+       for (i = 0; i < messagesLength; i++) {
+               if (event->type >> i == 1) {
+                       message = messages[i];
+               }
+       }
+
+       if (message != NULL) {
+               status = logEntry_create(event->bundleId, 
event->bundleSymbolicName, NULL, OSGI_LOGSERVICE_INFO, message, 0, &entry);
+               if (status == CELIX_SUCCESS) {
+                       status = log_addEntry(logger, entry);
+               }
+       }
+
+       return status;
+}
+
+celix_status_t log_frameworkEvent(void *listener, framework_event_pt event) {
+       celix_status_t status;
+       log_pt logger = ((framework_listener_pt) listener)->handle;
+       log_entry_pt entry = NULL;
+
+       status = logEntry_create(event->bundleId, event->bundleSymbolicName, 
NULL, (event->type == OSGI_FRAMEWORK_EVENT_ERROR) ? OSGI_LOGSERVICE_ERROR : 
OSGI_LOGSERVICE_INFO, event->error, event->errorCode, &entry);
+       if (status == CELIX_SUCCESS) {
+               status = log_addEntry(logger, entry);
+       }
+
+       return status;
+}
+
+celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener) {
+       celix_status_t status;
+
+       status = celixThreadMutex_lock(&logger->listenerLock);
+
+       if (status == CELIX_SUCCESS) {
+               arrayList_add(logger->listeners, listener);
+               log_startListenerThread(logger);
+
+               status = celixThreadMutex_unlock(&logger->listenerLock);
+       }
+
+       return status;
+}
+
+celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
+       celix_status_t status = CELIX_SUCCESS;
+
+    status += celixThreadMutex_lock(&logger->deliverLock);
+    status += celixThreadMutex_lock(&logger->listenerLock);
+
+       if (status == CELIX_SUCCESS) {
+           bool last = false;
+
+               arrayList_removeElement(logger->listeners, listener);
+               if (arrayList_size(logger->listeners) == 0) {
+                       status = log_stopListenerThread(logger);
+                       last = true;
+               }
+
+        status += celixThreadMutex_unlock(&logger->listenerLock);
+        status += celixThreadMutex_unlock(&logger->deliverLock);
+
+               if (last) {
+                   status += celixThread_join(logger->listenerThread, NULL);
+               }
+       }
+
+       if (status != CELIX_SUCCESS) {
+               status = CELIX_SERVICE_EXCEPTION;
+       }
+
+       return status;
+}
+
+celix_status_t log_removeAllLogListener(log_pt logger) {
+       celix_status_t status;
+
+       status = celixThreadMutex_lock(&logger->listenerLock);
+
+    if (status == CELIX_SUCCESS) {
+       arrayList_clear(logger->listeners);
+
+       status = celixThreadMutex_unlock(&logger->listenerLock);
+    }
+
+       return status;
+}
+
+static celix_status_t log_startListenerThread(log_pt logger) {
+       celix_status_t status;
+
+       logger->running = true;
+    logger->running = true;
+    status = celixThread_create(&logger->listenerThread, NULL, 
log_listenerThread, logger);
+
+       return status;
+}
+
+static celix_status_t log_stopListenerThread(log_pt logger) {
+       celix_status_t status;
+
+       logger->running = false;
+
+       status = celixThreadCondition_signal(&logger->entriesToDeliver);
+
+       return status;
+}
+
+static void * log_listenerThread(void *data) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       log_pt logger = data;
+
+       while (logger->running) {
+
+               status = celixThreadMutex_lock(&logger->deliverLock);
+
+               if ( status != CELIX_SUCCESS) {
+                       logger->running = false;
+               }
+               else {
+                       if (!arrayList_isEmpty(logger->listenerEntries)) {
+                               log_entry_pt entry = (log_entry_pt) 
arrayList_remove(logger->listenerEntries, 0);
+
+                               if (entry) {
+                                       status = 
celixThreadMutex_lock(&logger->listenerLock);
+                                       if (status != CELIX_SUCCESS) {
+                                               logger->running = false;
+                                               break;
+                                       } else {
+                                               array_list_iterator_pt it = 
arrayListIterator_create(logger->listeners);
+                                               while 
(arrayListIterator_hasNext(it)) {
+                                                       log_listener_pt 
listener = arrayListIterator_next(it);
+                                                       
listener->logged(listener, entry);
+                                               }
+                                               arrayListIterator_destroy(it);
+
+                                               // destroy not-stored entries
+                                               if (!(logger->store_debug || 
entry->level != OSGI_LOGSERVICE_DEBUG)) {
+                                                       
logEntry_destroy(&entry);
+                                               }
+
+                                               status = 
celixThreadMutex_unlock(&logger->listenerLock);
+                                               if (status != CELIX_SUCCESS) {
+                                                       logger->running = false;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (arrayList_isEmpty(logger->listenerEntries) && 
logger->running) {
+                               
celixThreadCondition_wait(&logger->entriesToDeliver, &logger->deliverLock);
+                       }
+
+                       status = celixThreadMutex_unlock(&logger->deliverLock);
+
+                       if (status != CELIX_SUCCESS) {
+                               logger->running = false;
+                               break;
+                       }
+               }
+
+       }
+
+    celixThread_exit(NULL);
+    return NULL;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log.h
----------------------------------------------------------------------
diff --git a/log_service/src/log.h b/log_service/src/log.h
new file mode 100644
index 0000000..e0d7b87
--- /dev/null
+++ b/log_service/src/log.h
@@ -0,0 +1,48 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include "linked_list.h"
+#include "log_entry.h"
+#include "log_listener.h"
+
+typedef struct log * log_pt;
+
+celix_status_t log_create(int max_size, bool store_debug, log_pt *logger);
+celix_status_t log_destroy(log_pt logger);
+celix_status_t log_addEntry(log_pt log, log_entry_pt entry);
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list);
+
+celix_status_t log_bundleChanged(void *listener, bundle_event_pt event);
+celix_status_t log_frameworkEvent(void *listener, framework_event_pt event);
+
+celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener);
+celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener);
+celix_status_t log_removeAllLogListener(log_pt logger);
+
+#endif /* LOG_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_entry.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_entry.c b/log_service/src/log_entry.c
new file mode 100644
index 0000000..3a8603a
--- /dev/null
+++ b/log_service/src/log_entry.c
@@ -0,0 +1,94 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_entry.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "celix_errno.h"
+#include "log_service.h"
+#include "log_entry.h"
+
+celix_status_t logEntry_create(long bundleId, const char* bundleSymbolicName , 
service_reference_pt reference,
+        log_level_t level, char *message, int errorCode,
+        log_entry_pt *entry) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *entry = malloc(sizeof(**entry));
+    if (*entry == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        (*entry)->level = level;
+        (*entry)->message = strdup(message);
+        (*entry)->errorCode = errorCode;
+        (*entry)->time = time(NULL);
+
+        (*entry)->bundleSymbolicName = strdup(bundleSymbolicName);
+        (*entry)->bundleId = bundleId;
+    }
+
+    return status;
+}
+
+celix_status_t logEntry_destroy(log_entry_pt *entry) {
+    if (*entry) {
+       free((*entry)->bundleSymbolicName);
+        free((*entry)->message);
+        free(*entry);
+        *entry = NULL;
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, const char** 
bundleSymbolicName) {
+    *bundleSymbolicName = entry->bundleSymbolicName;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId) {
+    *bundleId = entry->bundleId;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getErrorCode(log_entry_pt entry, int *errorCode) {
+    *errorCode = entry->errorCode;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getLevel(log_entry_pt entry, log_level_t *level) {
+    *level = entry->level;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getMessage(log_entry_pt entry, const char **message) {
+    *message = entry->message;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time) {
+    *time = entry->time;
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_factory.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_factory.c b/log_service/src/log_factory.c
new file mode 100644
index 0000000..1c0a17a
--- /dev/null
+++ b/log_service/src/log_factory.c
@@ -0,0 +1,100 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_factory.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+
+#include "service_factory.h"
+#include "log_factory.h"
+#include "log_service_impl.h"
+
+struct log_service_factory {
+    log_pt log;
+};
+
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *factory = calloc(1, sizeof(**factory));
+    if (*factory == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        log_service_factory_pt factoryData = calloc(1, sizeof(*factoryData));
+        if (factoryData == NULL) {
+            status = CELIX_ENOMEM;
+        } else {
+            factoryData->log = log;
+
+            (*factory)->handle = factoryData;
+            (*factory)->getService = logFactory_getService;
+            (*factory)->ungetService = logFactory_ungetService;
+        }
+    }
+
+    return status;
+}
+
+celix_status_t logFactory_destroy(service_factory_pt *factory) {
+    celix_status_t status = CELIX_SUCCESS;
+
+
+    free((*factory)->handle);
+    free(*factory);
+
+    factory = NULL;
+
+    return status;
+}
+
+
+celix_status_t logFactory_getService(void *factory, bundle_pt bundle, 
service_registration_pt registration, void **service) {
+    log_service_factory_pt log_factory = factory;
+    log_service_pt log_service = NULL;
+    log_service_data_pt log_service_data = NULL;
+
+    logService_create(log_factory->log, bundle, &log_service_data);
+
+    log_service = calloc(1, sizeof(*log_service));
+    log_service->logger = log_service_data;
+    log_service->log = logService_log;
+  //  log_service->logSr = logService_logSr;
+
+    (*service) = log_service;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, 
service_registration_pt registration, void **service) {
+       log_service_pt log_service = *service;
+
+       logService_destroy(&log_service->logger);
+
+       free(*service);
+       *service = NULL;
+
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_factory.h
----------------------------------------------------------------------
diff --git a/log_service/src/log_factory.h b/log_service/src/log_factory.h
new file mode 100644
index 0000000..8ebe5f8
--- /dev/null
+++ b/log_service/src/log_factory.h
@@ -0,0 +1,40 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_factory.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#ifndef LOG_FACTORY_H_
+#define LOG_FACTORY_H_
+
+#include "log.h"
+
+typedef struct log_service_factory * log_service_factory_pt;
+
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory);
+celix_status_t logFactory_destroy(service_factory_pt *factory);
+celix_status_t logFactory_getService(void *factory, bundle_pt bundle, 
service_registration_pt registration, void **service);
+celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, 
service_registration_pt registration, void **service);
+
+
+#endif /* LOG_FACTORY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_helper.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_helper.c b/log_service/src/log_helper.c
new file mode 100644
index 0000000..c0cd309
--- /dev/null
+++ b/log_service/src/log_helper.c
@@ -0,0 +1,211 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_helper.c
+ *
+ *  \date       Nov 10, 2014
+ *  \author     <a href="mailto:[email protected]";>Apache Celix Project 
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "bundle_context.h"
+#include "service_tracker.h"
+#include "celix_threads.h"
+#include "array_list.h"
+
+#include "celix_errno.h"
+#include "log_service.h"
+
+#include "log_helper.h"
+
+#define LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME         
"LOGHELPER_ENABLE_STDOUT_FALLBACK"
+
+
+struct log_helper {
+       bundle_context_pt bundleContext;
+    service_tracker_pt logServiceTracker;
+       celix_thread_mutex_t logListLock;
+       array_list_pt logServices;
+       bool stdOutFallback;
+};
+
+celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt 
reference, void *service);
+celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt 
reference, void *service);
+
+
+celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* 
loghelper)
+{
+       celix_status_t status = CELIX_SUCCESS;
+
+       (*loghelper) = calloc(1, sizeof(**loghelper));
+
+       if (!(*loghelper))
+       {
+               status = CELIX_ENOMEM;
+       }
+       else
+       {
+               const char* stdOutFallbackStr = NULL;
+               (*loghelper)->bundleContext = context;
+               (*loghelper)->logServiceTracker = NULL;
+               (*loghelper)->stdOutFallback = false;
+
+               bundleContext_getProperty(context, 
LOGHELPER_ENABLE_STDOUT_FALLBACK_PROPERTY_NAME, &stdOutFallbackStr);
+
+               if (stdOutFallbackStr != NULL) {
+                       (*loghelper)->stdOutFallback = true;
+               }
+
+               pthread_mutex_init(&(*loghelper)->logListLock, NULL);
+        arrayList_create(&(*loghelper)->logServices);
+       }
+
+       return status;
+}
+
+celix_status_t logHelper_start(log_helper_pt loghelper)
+{
+       celix_status_t status;
+       service_tracker_customizer_pt logTrackerCustomizer = NULL;
+
+       status = serviceTrackerCustomizer_create(loghelper, NULL, 
logHelper_logServiceAdded, NULL, logHelper_logServiceRemoved, 
&logTrackerCustomizer);
+
+       if (status == CELIX_SUCCESS) {
+        loghelper->logServiceTracker = NULL;
+               status = serviceTracker_create(loghelper->bundleContext, 
(char*) OSGI_LOGSERVICE_NAME, logTrackerCustomizer, 
&loghelper->logServiceTracker);
+       }
+
+       if (status == CELIX_SUCCESS) {
+               status = serviceTracker_open(loghelper->logServiceTracker);
+       }
+
+       return status;
+}
+
+
+
+celix_status_t logHelper_logServiceAdded(void *handle, service_reference_pt 
reference, void *service)
+{
+       log_helper_pt loghelper = handle;
+
+       pthread_mutex_lock(&loghelper->logListLock);
+       arrayList_add(loghelper->logServices, service);
+       pthread_mutex_unlock(&loghelper->logListLock);
+
+       return CELIX_SUCCESS;
+}
+
+celix_status_t logHelper_logServiceRemoved(void *handle, service_reference_pt 
reference, void *service)
+{
+       log_helper_pt loghelper = handle;
+
+       pthread_mutex_lock(&loghelper->logListLock);
+       arrayList_removeElement(loghelper->logServices, service);
+       pthread_mutex_unlock(&loghelper->logListLock);
+
+       return CELIX_SUCCESS;
+}
+
+
+celix_status_t logHelper_stop(log_helper_pt loghelper) {
+       celix_status_t status;
+
+    status = serviceTracker_close(loghelper->logServiceTracker);
+
+    return status;
+}
+
+celix_status_t logHelper_destroy(log_helper_pt* loghelper) {
+        celix_status_t status = CELIX_SUCCESS;
+
+        if((*loghelper)->logServiceTracker){
+               serviceTracker_destroy((*loghelper)->logServiceTracker);
+        }
+
+        pthread_mutex_lock(&(*loghelper)->logListLock);
+        arrayList_destroy((*loghelper)->logServices);
+       pthread_mutex_unlock(&(*loghelper)->logListLock);
+
+        pthread_mutex_destroy(&(*loghelper)->logListLock);
+
+        free(*loghelper);
+        *loghelper = NULL;
+        return status;
+}
+
+
+
+
+celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* 
message, ... )
+{
+    celix_status_t status = CELIX_SUCCESS;
+       va_list listPointer;
+    char msg[1024];
+    msg[0] = '\0';
+    bool logged = false;
+
+    if(loghelper == NULL){
+       return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+       va_start(listPointer, message);
+       vsnprintf(msg, 1024, message, listPointer);
+
+       pthread_mutex_lock(&loghelper->logListLock);
+
+       int i = 0;
+       for (; i < arrayList_size(loghelper->logServices); i++) {
+               log_service_pt logService = 
arrayList_get(loghelper->logServices, i);
+               if (logService != NULL) {
+                       (logService->log)(logService->logger, level, msg);
+                       logged = true;
+               }
+       }
+
+       pthread_mutex_unlock(&loghelper->logListLock);
+
+    if (!logged && loghelper->stdOutFallback) {
+        char *levelStr = NULL;
+
+        switch (level) {
+            case OSGI_LOGSERVICE_ERROR:
+                levelStr = "ERROR";
+                break;
+            case OSGI_LOGSERVICE_WARNING:
+                levelStr = "WARNING";
+                break;
+            case OSGI_LOGSERVICE_INFO:
+                levelStr = "INFO";
+                break;
+            case OSGI_LOGSERVICE_DEBUG:
+            default:
+                levelStr = "DEBUG";
+                break;
+        }
+
+        printf("%s: %s\n", levelStr, msg);
+    }
+
+    va_end(listPointer);
+
+       return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_reader_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_reader_service_impl.c 
b/log_service/src/log_reader_service_impl.c
new file mode 100644
index 0000000..2a46ea7
--- /dev/null
+++ b/log_service/src/log_reader_service_impl.c
@@ -0,0 +1,82 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+ /*
+ * log_reader_service_impl.c
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+
+#include "log_reader_service_impl.h"
+#include "celixbool.h"
+
+struct log_reader_data {
+    log_pt log;
+};
+
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader) 
{
+    celix_status_t status = CELIX_SUCCESS;
+
+    *reader = (log_reader_data_pt) calloc(1, sizeof(**reader));
+
+    if (*reader == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        (*reader)->log = log;
+    }
+
+    return status;
+}
+
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*reader);
+    reader = NULL;
+
+    return status;
+}
+
+
+
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, 
linked_list_pt *list) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    status = log_getEntries(reader->log, list);
+
+    return status;
+}
+
+celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, 
log_listener_pt listener) {
+    return log_addLogListener(reader->log, listener);
+}
+
+celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, 
log_listener_pt listener) {
+    return log_removeLogListener(reader->log, listener);
+}
+
+celix_status_t logReaderService_removeAllLogListener(log_reader_data_pt 
reader) {
+    return log_removeAllLogListener(reader->log);
+}
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_reader_service_impl.h
----------------------------------------------------------------------
diff --git a/log_service/src/log_reader_service_impl.h 
b/log_service/src/log_reader_service_impl.h
new file mode 100644
index 0000000..71829f2
--- /dev/null
+++ b/log_service/src/log_reader_service_impl.h
@@ -0,0 +1,43 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_reader_service_impl.h
+ *
+ *  \date       Jun 26, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#ifndef LOG_READER_SERVICE_IMPL_H_
+#define LOG_READER_SERVICE_IMPL_H_
+
+#include "log_reader_service.h"
+#include "log.h"
+
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader);
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader);
+
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, 
linked_list_pt *list);
+
+celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, 
log_listener_pt listener);
+celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, 
log_listener_pt listener);
+celix_status_t logReaderService_removeAllLogListener(log_reader_data_pt 
reader);
+
+
+#endif /* LOG_READER_SERVICE_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_service_activator.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_service_activator.c 
b/log_service/src/log_service_activator.c
new file mode 100644
index 0000000..8c72fb1
--- /dev/null
+++ b/log_service/src/log_service_activator.c
@@ -0,0 +1,198 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_service_activator.c
+ *
+ *  \date       Jun 25, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <constants.h>
+
+#include "bundle_activator.h"
+#include "log_service_impl.h"
+#include "service_factory.h"
+#include "log_factory.h"
+#include "log.h"
+#include "log_reader_service_impl.h"
+#include "service_registration.h"
+
+#define DEFAULT_MAX_SIZE 100
+#define DEFAULT_STORE_DEBUG false
+
+#define MAX_SIZE_PROPERTY "CELIX_LOG_MAX_SIZE"
+#define STORE_DEBUG_PROPERTY "CELIX_LOG_STORE_DEBUG"
+
+struct logActivator {
+    bundle_context_pt bundleContext;
+    service_registration_pt logServiceFactoryReg;
+    service_registration_pt logReaderServiceReg;
+
+    bundle_listener_pt bundleListener;
+    framework_listener_pt frameworkListener;
+
+    log_pt logger;
+    service_factory_pt factory;
+    log_reader_data_pt reader;
+    log_reader_service_pt reader_service;
+};
+
+static celix_status_t bundleActivator_getMaxSize(struct logActivator 
*activator, int *max_size);
+static celix_status_t bundleActivator_getStoreDebug(struct logActivator 
*activator, bool *store_debug);
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void 
**userData) {
+    celix_status_t status = CELIX_SUCCESS;
+       struct logActivator * activator = NULL;
+
+    activator = (struct logActivator *) calloc(1, sizeof(struct logActivator));
+
+    if (activator == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+               activator->bundleContext = context;
+               activator->logServiceFactoryReg = NULL;
+               activator->logReaderServiceReg = NULL;
+
+               activator->logger = NULL;
+               activator->factory = NULL;
+               activator->reader = NULL;
+               activator->reader_service = NULL;
+
+        *userData = activator;
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt 
context) {
+    struct logActivator * activator = (struct logActivator *) userData;
+    celix_status_t status = CELIX_SUCCESS;
+
+    int max_size = 0;
+    bool store_debug = false;
+
+    bundleActivator_getMaxSize(activator, &max_size);
+    bundleActivator_getStoreDebug(activator, &store_debug);
+
+    log_create(max_size, store_debug, &activator->logger);
+
+    // Add logger as Bundle- and FrameworkEvent listener
+    activator->bundleListener = calloc(1, sizeof(*activator->bundleListener));
+    activator->bundleListener->handle = activator->logger;
+    activator->bundleListener->bundleChanged = log_bundleChanged;
+    bundleContext_addBundleListener(context, activator->bundleListener);
+
+    activator->frameworkListener = calloc(1, 
sizeof(*activator->frameworkListener));
+    activator->frameworkListener->handle = activator->logger;
+    activator->frameworkListener->frameworkEvent = log_frameworkEvent;
+    bundleContext_addFrameworkListener(context, activator->frameworkListener);
+
+    logFactory_create(activator->logger, &activator->factory);
+
+       properties_pt props = properties_create();
+       properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, 
CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+
+
+       bundleContext_registerServiceFactory(context, (char *) 
OSGI_LOGSERVICE_NAME, activator->factory, props, 
&activator->logServiceFactoryReg);
+
+    logReaderService_create(activator->logger, &activator->reader);
+
+    activator->reader_service = calloc(1, sizeof(*activator->reader_service));
+    activator->reader_service->reader = activator->reader;
+    activator->reader_service->getLog = logReaderService_getLog;
+    activator->reader_service->addLogListener = 
logReaderService_addLogListener;
+    activator->reader_service->removeLogListener = 
logReaderService_removeLogListener;
+    activator->reader_service->removeAllLogListener = 
logReaderService_removeAllLogListener;
+
+       props = properties_create();
+       properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, 
CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+
+    bundleContext_registerService(context, (char *) 
OSGI_LOGSERVICE_READER_SERVICE_NAME, activator->reader_service, props, 
&activator->logReaderServiceReg);
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt 
context) {
+       struct logActivator * activator = (struct logActivator *) userData;
+
+       serviceRegistration_unregister(activator->logReaderServiceReg);
+       activator->logReaderServiceReg = NULL;
+       serviceRegistration_unregister(activator->logServiceFactoryReg);
+       activator->logServiceFactoryReg = NULL;
+
+    logReaderService_destroy(&activator->reader);
+       free(activator->reader_service);
+
+       logFactory_destroy(&activator->factory);
+
+       bundleContext_removeBundleListener(context, activator->bundleListener);
+       bundleContext_removeFrameworkListener(context, 
activator->frameworkListener);
+
+       free(activator->bundleListener);
+       free(activator->frameworkListener);
+
+       log_destroy(activator->logger);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt 
context) {
+       struct logActivator * activator = (struct logActivator *) userData;
+
+       free(activator);
+
+    return CELIX_SUCCESS;
+}
+
+static celix_status_t bundleActivator_getMaxSize(struct logActivator 
*activator, int *max_size) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       const char *max_size_str = NULL;
+
+       *max_size = DEFAULT_MAX_SIZE;
+
+       bundleContext_getProperty(activator->bundleContext, MAX_SIZE_PROPERTY, 
&max_size_str);
+       if (max_size_str) {
+               *max_size = atoi(max_size_str);
+       }
+
+       return status;
+}
+
+static celix_status_t bundleActivator_getStoreDebug(struct logActivator 
*activator, bool *store_debug) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       const char *store_debug_str = NULL;
+
+       *store_debug = DEFAULT_STORE_DEBUG;
+
+       bundleContext_getProperty(activator->bundleContext, 
STORE_DEBUG_PROPERTY, &store_debug_str);
+       if (store_debug_str) {
+               if (strcasecmp(store_debug_str, "true") == 0) {
+                       *store_debug = true;
+               } else if (strcasecmp(store_debug_str, "false") == 0) {
+                       *store_debug = false;
+               }
+       }
+
+       return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/src/log_service_impl.c 
b/log_service/src/log_service_impl.c
new file mode 100644
index 0000000..a77e9ad
--- /dev/null
+++ b/log_service/src/log_service_impl.c
@@ -0,0 +1,96 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_service_impl.c
+ *
+ *  \date       Jun 22, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include "log_service_impl.h"
+#include "module.h"
+#include "bundle.h"
+
+struct log_service_data {
+    log_pt log;
+    bundle_pt bundle;
+};
+
+celix_status_t logService_create(log_pt log, bundle_pt bundle, 
log_service_data_pt *logger) {
+    celix_status_t status = CELIX_SUCCESS;
+    *logger = calloc(1, sizeof(struct log_service_data));
+    if (*logger == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        (*logger)->bundle = bundle;
+        (*logger)->log = log;
+    }
+
+    return status;
+}
+
+celix_status_t logService_destroy(log_service_data_pt *logger) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*logger);
+    logger = NULL;
+
+    return status;
+}
+
+celix_status_t logService_log(log_service_data_pt logger, log_level_t level, 
char * message) {
+    return logService_logSr(logger, NULL, level, message);
+}
+
+celix_status_t logService_logSr(log_service_data_pt logger, 
service_reference_pt reference, log_level_t level, char * message) {
+    celix_status_t status;
+    log_entry_pt entry = NULL;
+    bundle_pt bundle = logger->bundle;
+    bundle_archive_pt archive = NULL;
+    module_pt module = NULL;
+    const char *symbolicName = NULL;
+    long bundleId = -1;
+
+    if (reference != NULL) {
+       serviceReference_getBundle(reference, &bundle);
+    }
+
+    status = bundle_getArchive(bundle, &archive);
+
+    if (status == CELIX_SUCCESS) {
+        status = bundleArchive_getId(archive, &bundleId);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = bundle_getCurrentModule(bundle, &module);
+
+        if (status == CELIX_SUCCESS) {
+            status = module_getSymbolicName(module, &symbolicName);
+        }
+    }
+
+    if(status == CELIX_SUCCESS && symbolicName != NULL && message != NULL){
+       status = logEntry_create(bundleId, symbolicName, reference, level, 
message, 0, &entry);
+       log_addEntry(logger->log, entry);
+    }
+
+    return status;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_service/src/log_service_impl.h
----------------------------------------------------------------------
diff --git a/log_service/src/log_service_impl.h 
b/log_service/src/log_service_impl.h
new file mode 100644
index 0000000..04c986e
--- /dev/null
+++ b/log_service/src/log_service_impl.h
@@ -0,0 +1,39 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_service_impl.h
+ *
+ *  \date       Jun 22, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#ifndef LOG_SERVICE_IMPL_H_
+#define LOG_SERVICE_IMPL_H_
+
+#include "log_service.h"
+#include "log.h"
+
+celix_status_t logService_create(log_pt log, bundle_pt bundle, 
log_service_data_pt *logger);
+celix_status_t logService_destroy(log_service_data_pt *logger);
+celix_status_t logService_log(log_service_data_pt logger, log_level_t level, 
char * message);
+celix_status_t logService_logSr(log_service_data_pt logger, 
service_reference_pt reference, log_level_t level, char * message);
+
+
+#endif /* LOG_SERVICE_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/CMakeLists.txt b/log_writer/CMakeLists.txt
index 4692d7a..a742af2 100644
--- a/log_writer/CMakeLists.txt
+++ b/log_writer/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 celix_subproject(LOG_WRITER "Option to enable building the Log Writer bundles" 
ON DEPS FRAMEWORK LOG_SERVICE)
 if (LOG_WRITER)
+    add_subdirectory(log_writer)
     add_subdirectory(log_writer_stdout)
        add_subdirectory(log_writer_syslog) 
 endif (LOG_WRITER)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/CMakeLists.txt 
b/log_writer/log_writer/CMakeLists.txt
new file mode 100644
index 0000000..09aa9cf
--- /dev/null
+++ b/log_writer/log_writer/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+add_library(log_writer_common STATIC
+               src/log_writer.c
+               src/log_writer_activator.c
+)
+target_include_directories(log_writer_common PRIVATE src)
+target_include_directories(log_writer_common PUBLIC include)
+target_link_libraries(log_writer_common PUBLIC Celix::log_service_api 
Celix::framework)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/include/log_writer.h
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/include/log_writer.h 
b/log_writer/log_writer/include/log_writer.h
new file mode 100644
index 0000000..b4b70d0
--- /dev/null
+++ b/log_writer/log_writer/include/log_writer.h
@@ -0,0 +1,53 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_writer.h
+ *
+ *  \date       Jul 4, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+
+#ifndef LOG_WRITER_H_
+#define LOG_WRITER_H_
+
+#include "log_reader_service.h"
+#include "service_tracker.h"
+
+struct log_writer {
+    log_reader_service_pt logReader;
+    log_listener_pt logListener;
+
+    bundle_context_pt context;
+    service_tracker_pt tracker;
+};
+
+typedef struct log_writer *log_writer_pt;
+
+celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt 
*writer);
+celix_status_t logWriter_destroy(log_writer_pt *writer);
+celix_status_t logWriter_start(log_writer_pt writer);
+celix_status_t logWriter_stop(log_writer_pt writer);
+
+celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, 
void **service);
+celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, 
void * service);
+celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, 
void * service);
+celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, 
void * service);
+
+#endif /* LOG_WRITER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/private/include/log_writer.h
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/private/include/log_writer.h 
b/log_writer/log_writer/private/include/log_writer.h
deleted file mode 100644
index fdf65c8..0000000
--- a/log_writer/log_writer/private/include/log_writer.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_writer.h
- *
- *  \date       Jul 4, 2011
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-
-#ifndef LOG_WRITER_H_
-#define LOG_WRITER_H_
-
-#include "log_reader_service.h"
-
-#include "service_tracker.h"
-
-struct log_writer {
-    log_reader_service_pt logReader;
-    log_listener_pt logListener;
-
-    bundle_context_pt context;
-    service_tracker_pt tracker;
-};
-
-typedef struct log_writer *log_writer_pt;
-
-celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt 
*writer);
-celix_status_t logWriter_destroy(log_writer_pt *writer);
-celix_status_t logWriter_start(log_writer_pt writer);
-celix_status_t logWriter_stop(log_writer_pt writer);
-
-celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, 
void **service);
-celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, 
void * service);
-celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, 
void * service);
-celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, 
void * service);
-
-#endif /* LOG_WRITER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/private/src/log_writer.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/private/src/log_writer.c 
b/log_writer/log_writer/private/src/log_writer.c
deleted file mode 100644
index 685c1a5..0000000
--- a/log_writer/log_writer/private/src/log_writer.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_writer.c
- *
- *  \date       Mar 7, 2011
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "celix_errno.h"
-#include "celixbool.h"
-
-#include "log_writer.h"
-#include "log_listener.h"
-#include "module.h"
-#include "bundle.h"
-
-celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt 
*writer) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       *writer = calloc(1, sizeof(**writer));
-       (*writer)->logListener = calloc(1, sizeof(*(*writer)->logListener));
-       (*writer)->logListener->handle = *writer;
-       (*writer)->logListener->logged = logListener_logged;
-       (*writer)->logReader = NULL;
-       (*writer)->context = context;
-       (*writer)->tracker = NULL;
-
-       return status;
-}
-
-
-celix_status_t logWriter_destroy(log_writer_pt *writer) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       free((*writer)->logListener);
-       free(*writer);
-
-       writer = NULL;
-
-       return status;
-}
-celix_status_t logWriter_start(log_writer_pt writer) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       service_tracker_customizer_pt cust = NULL;
-       service_tracker_pt tracker = NULL;
-
-       status = serviceTrackerCustomizer_create(writer, logWriter_addingServ, 
logWriter_addedServ, logWriter_modifiedServ, logWriter_removedServ, &cust);
-       if (status == CELIX_SUCCESS) {
-               status = serviceTracker_create(writer->context, (char *) 
OSGI_LOGSERVICE_READER_SERVICE_NAME, cust, &tracker);
-               if (status == CELIX_SUCCESS) {
-                       writer->tracker = tracker;
-                       status = serviceTracker_open(tracker);
-               }
-       }
-
-       return status;
-}
-
-celix_status_t logWriter_stop(log_writer_pt writer) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       if (serviceTracker_close(writer->tracker) != CELIX_SUCCESS) {
-               status = CELIX_BUNDLE_EXCEPTION;
-       }
-       if (serviceTracker_destroy(writer->tracker) != CELIX_SUCCESS) {
-               status = CELIX_BUNDLE_EXCEPTION;
-       }
-
-       return status;
-}
-
-celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, 
void **service) {
-       log_writer_pt writer = (log_writer_pt) handle;
-       bundleContext_getService(writer->context, ref, service);
-       return CELIX_SUCCESS;
-}
-
-celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, 
void * service) {
-       log_writer_pt writer = (log_writer_pt) handle;
-
-       // Add this writer to each log reader service found
-       if (service != NULL) {
-               ((log_reader_service_pt) 
service)->addLogListener(((log_reader_service_pt) service)->reader, 
writer->logListener);
-       }
-
-       return CELIX_SUCCESS;
-}
-
-celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, 
void * service) {
-       return CELIX_SUCCESS;
-}
-
-celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, 
void * service) {
-       log_writer_pt writer = (log_writer_pt) handle;
-
-       if (service != NULL) {
-               ((log_reader_service_pt) 
service)->removeLogListener(((log_reader_service_pt) service)->reader, 
writer->logListener);
-       }
-
-       return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/private/src/log_writer_activator.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/private/src/log_writer_activator.c 
b/log_writer/log_writer/private/src/log_writer_activator.c
deleted file mode 100644
index 248cad6..0000000
--- a/log_writer/log_writer/private/src/log_writer_activator.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_writer_activator.c
- *
- *  \date       Oct 1, 2013
- *  \author     <a href="mailto:[email protected]";>Apache Celix Project 
Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include "log_writer.h"
-
-#include "bundle_activator.h"
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void 
**userData) {
-       log_writer_pt writer = NULL;
-
-       logWriter_create(context, &writer);
-
-       *userData = writer;
-
-       return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt 
context) {
-       log_writer_pt writer = (log_writer_pt) userData;
-
-       return logWriter_start(writer);
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt 
context) {
-       log_writer_pt writer = (log_writer_pt) userData;
-
-       return logWriter_stop(writer);
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt 
context) {
-       log_writer_pt writer = (log_writer_pt) userData;
-
-       return logWriter_destroy(&writer);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/src/log_writer.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/src/log_writer.c 
b/log_writer/log_writer/src/log_writer.c
new file mode 100644
index 0000000..685c1a5
--- /dev/null
+++ b/log_writer/log_writer/src/log_writer.c
@@ -0,0 +1,122 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_writer.c
+ *
+ *  \date       Mar 7, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "celix_errno.h"
+#include "celixbool.h"
+
+#include "log_writer.h"
+#include "log_listener.h"
+#include "module.h"
+#include "bundle.h"
+
+celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt 
*writer) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       *writer = calloc(1, sizeof(**writer));
+       (*writer)->logListener = calloc(1, sizeof(*(*writer)->logListener));
+       (*writer)->logListener->handle = *writer;
+       (*writer)->logListener->logged = logListener_logged;
+       (*writer)->logReader = NULL;
+       (*writer)->context = context;
+       (*writer)->tracker = NULL;
+
+       return status;
+}
+
+
+celix_status_t logWriter_destroy(log_writer_pt *writer) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       free((*writer)->logListener);
+       free(*writer);
+
+       writer = NULL;
+
+       return status;
+}
+celix_status_t logWriter_start(log_writer_pt writer) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       service_tracker_customizer_pt cust = NULL;
+       service_tracker_pt tracker = NULL;
+
+       status = serviceTrackerCustomizer_create(writer, logWriter_addingServ, 
logWriter_addedServ, logWriter_modifiedServ, logWriter_removedServ, &cust);
+       if (status == CELIX_SUCCESS) {
+               status = serviceTracker_create(writer->context, (char *) 
OSGI_LOGSERVICE_READER_SERVICE_NAME, cust, &tracker);
+               if (status == CELIX_SUCCESS) {
+                       writer->tracker = tracker;
+                       status = serviceTracker_open(tracker);
+               }
+       }
+
+       return status;
+}
+
+celix_status_t logWriter_stop(log_writer_pt writer) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       if (serviceTracker_close(writer->tracker) != CELIX_SUCCESS) {
+               status = CELIX_BUNDLE_EXCEPTION;
+       }
+       if (serviceTracker_destroy(writer->tracker) != CELIX_SUCCESS) {
+               status = CELIX_BUNDLE_EXCEPTION;
+       }
+
+       return status;
+}
+
+celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, 
void **service) {
+       log_writer_pt writer = (log_writer_pt) handle;
+       bundleContext_getService(writer->context, ref, service);
+       return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, 
void * service) {
+       log_writer_pt writer = (log_writer_pt) handle;
+
+       // Add this writer to each log reader service found
+       if (service != NULL) {
+               ((log_reader_service_pt) 
service)->addLogListener(((log_reader_service_pt) service)->reader, 
writer->logListener);
+       }
+
+       return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, 
void * service) {
+       return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, 
void * service) {
+       log_writer_pt writer = (log_writer_pt) handle;
+
+       if (service != NULL) {
+               ((log_reader_service_pt) 
service)->removeLogListener(((log_reader_service_pt) service)->reader, 
writer->logListener);
+       }
+
+       return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer/src/log_writer_activator.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer/src/log_writer_activator.c 
b/log_writer/log_writer/src/log_writer_activator.c
new file mode 100644
index 0000000..248cad6
--- /dev/null
+++ b/log_writer/log_writer/src/log_writer_activator.c
@@ -0,0 +1,57 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_writer_activator.c
+ *
+ *  \date       Oct 1, 2013
+ *  \author     <a href="mailto:[email protected]";>Apache Celix Project 
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include "log_writer.h"
+
+#include "bundle_activator.h"
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void 
**userData) {
+       log_writer_pt writer = NULL;
+
+       logWriter_create(context, &writer);
+
+       *userData = writer;
+
+       return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt 
context) {
+       log_writer_pt writer = (log_writer_pt) userData;
+
+       return logWriter_start(writer);
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt 
context) {
+       log_writer_pt writer = (log_writer_pt) userData;
+
+       return logWriter_stop(writer);
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt 
context) {
+       log_writer_pt writer = (log_writer_pt) userData;
+
+       return logWriter_destroy(&writer);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_stdout/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_stdout/CMakeLists.txt 
b/log_writer/log_writer_stdout/CMakeLists.txt
index 7874e96..11734cc 100644
--- a/log_writer/log_writer_stdout/CMakeLists.txt
+++ b/log_writer/log_writer_stdout/CMakeLists.txt
@@ -20,17 +20,13 @@ add_bundle(log_writer
        VERSION "1.1.0"
        NAME "Apache Celix Log Writer"
        SOURCES
-               
${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
-               
${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
-               
${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
+               
#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
+               
#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
+               
#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
 
-               private/src/log_writer_stdout
+               src/log_writer_stdout
 )
 
 install_bundle(log_writer)
-    
-target_link_libraries(log_writer celix_framework)
-    
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include")
+
+target_link_libraries(log_writer PRIVATE Celix::log_service_api 
log_writer_common)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_stdout/private/src/log_writer_stdout.c 
b/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
deleted file mode 100644
index d57e5d5..0000000
--- a/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you 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.
- */
-/*
- * log_writer_stdout.c
- *
- *  \date       Mar 7, 2011
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "celix_errno.h"
-#include "celixbool.h"
-
-#include "log_writer.h"
-#include "log_listener.h"
-
-#include "module.h"
-#include "bundle.h"
-
-celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt 
entry) {
-       celix_status_t status = CELIX_SUCCESS;
-
-    if (!entry) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-               printf("LogWriter: %s from %s\n", entry->message, 
entry->bundleSymbolicName);
-    }
-
-    return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_stdout/src/log_writer_stdout.c
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_stdout/src/log_writer_stdout.c 
b/log_writer/log_writer_stdout/src/log_writer_stdout.c
new file mode 100644
index 0000000..d57e5d5
--- /dev/null
+++ b/log_writer/log_writer_stdout/src/log_writer_stdout.c
@@ -0,0 +1,49 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you 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.
+ */
+/*
+ * log_writer_stdout.c
+ *
+ *  \date       Mar 7, 2011
+ *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "celix_errno.h"
+#include "celixbool.h"
+
+#include "log_writer.h"
+#include "log_listener.h"
+
+#include "module.h"
+#include "bundle.h"
+
+celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt 
entry) {
+       celix_status_t status = CELIX_SUCCESS;
+
+    if (!entry) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+               printf("LogWriter: %s from %s\n", entry->message, 
entry->bundleSymbolicName);
+    }
+
+    return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/log_writer/log_writer_syslog/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/log_writer/log_writer_syslog/CMakeLists.txt 
b/log_writer/log_writer_syslog/CMakeLists.txt
index 12130cf..caad713 100644
--- a/log_writer/log_writer_syslog/CMakeLists.txt
+++ b/log_writer/log_writer_syslog/CMakeLists.txt
@@ -23,18 +23,14 @@ if (LOG_WRITER_SYSLOG)
         SYMBOLIC_NAME "apache_celix_log_writer_syslog"
         NAME "Apache Celix Log Writer Syslog"
         SOURCES
-        
${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
-        ${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
-        
${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
 
-        private/src/log_writer_syslog
+            
#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer_activator
+            #${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/src/log_writer
+            
#${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include/log_writer.h
+            private/src/log_writer_syslog
     )
 
     install_bundle(log_writer_syslog)
-        
-    target_link_libraries(log_writer_syslog celix_framework)
-        
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-    
include_directories("${PROJECT_SOURCE_DIR}/log_writer/log_writer/private/include")
+
+    target_link_libraries(log_writer_syslog PRIVATE log_writer_common)
 endif (LOG_WRITER_SYSLOG)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/pubsub/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/pubsub/CMakeLists.txt b/pubsub/CMakeLists.txt
index 2c2c50f..a866ba4 100644
--- a/pubsub/CMakeLists.txt
+++ b/pubsub/CMakeLists.txt
@@ -23,9 +23,6 @@ if (PUBSUB)
                message(WARNING "Celix will now contain a dependency with a 
LGPL License (ZeroMQ). For more information about this, consult the 
pubsub/README.md file.")
                option(BUILD_ZMQ_SECURITY "Build with security for ZeroMQ." OFF)
     endif (BUILD_PUBSUB_PSA_ZMQ)
-
-       include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-       include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
        
        add_subdirectory(pubsub_topology_manager)
        add_subdirectory(pubsub_discovery)
@@ -45,6 +42,10 @@ if (PUBSUB)
                add_subdirectory(test)
        endif()
 
+       #api target
+       add_libary(pubsub_api INTERFACE)
+       target_include_directories(pubsub_api INTERFACE api)
+
        #install api
        install(FILES api/pubsub/publisher.h api/pubsub/subscriber.h 
DESTINATION include/celix/pubsub COMPONENT framework)
    
@@ -67,5 +68,7 @@ if (PUBSUB)
       DESTINATION share/celix/pubsub 
       COMPONENT framework
    )
-       
+
+       #Setup target aliases to match external usage
+       add_library(Celix::pubsub_api ALIAS pubsub_api)
 endif(PUBSUB)

Reply via email to