celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1642985 - in /celix/trunk/remote_services: discovery/private/include/ discovery/private/src/ discovery_configured/ discovery_configured/private/include/ discovery_configured/private/src/ discovery_etcd/ discovery_etcd/private/include/ disc...
Date Mon, 15 Dec 2014 17:11:36 GMT
Author: bpetri
Date: Tue Dec  2 18:33:43 2014
New Revision: 1642985

URL: http://svn.apache.org/r1642985
Log:
CELIX-182: replaced discovery fw_log calls w/ loghelper

Modified:
    celix/trunk/remote_services/discovery/private/include/endpoint_descriptor_reader.h
    celix/trunk/remote_services/discovery/private/include/endpoint_discovery_poller.h
    celix/trunk/remote_services/discovery/private/src/discovery.c
    celix/trunk/remote_services/discovery/private/src/discovery_activator.c
    celix/trunk/remote_services/discovery/private/src/endpoint_descriptor_reader.c
    celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
    celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c
    celix/trunk/remote_services/discovery_configured/CMakeLists.txt
    celix/trunk/remote_services/discovery_configured/private/include/discovery_impl.h
    celix/trunk/remote_services/discovery_configured/private/src/discovery_impl.c
    celix/trunk/remote_services/discovery_etcd/CMakeLists.txt
    celix/trunk/remote_services/discovery_etcd/private/include/discovery_impl.h
    celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c

Modified: celix/trunk/remote_services/discovery/private/include/endpoint_descriptor_reader.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/include/endpoint_descriptor_reader.h?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/include/endpoint_descriptor_reader.h (original)
+++ celix/trunk/remote_services/discovery/private/include/endpoint_descriptor_reader.h Tue
Dec  2 18:33:43 2014
@@ -27,12 +27,13 @@
 #ifndef ENDPOINT_DESCRIPTOR_READER_H_
 #define ENDPOINT_DESCRIPTOR_READER_H_
 
+#include "endpoint_discovery_poller.h"
 #include "celix_errno.h"
 #include "array_list.h"
 
 typedef struct endpoint_descriptor_reader *endpoint_descriptor_reader_pt;
 
-celix_status_t endpointDescriptorReader_create(endpoint_descriptor_reader_pt *reader);
+celix_status_t endpointDescriptorReader_create(endpoint_discovery_poller_pt poller, endpoint_descriptor_reader_pt
*reader);
 celix_status_t endpointDescriptorReader_destroy(endpoint_descriptor_reader_pt reader);
 
 celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader_pt reader,
char *document, array_list_pt *endpoints);

Modified: celix/trunk/remote_services/discovery/private/include/endpoint_discovery_poller.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/include/endpoint_discovery_poller.h?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/include/endpoint_discovery_poller.h (original)
+++ celix/trunk/remote_services/discovery/private/include/endpoint_discovery_poller.h Tue
Dec  2 18:33:43 2014
@@ -30,6 +30,18 @@
 #include "celix_errno.h"
 #include "discovery.h"
 
+struct endpoint_discovery_poller {
+    discovery_pt discovery;
+    hash_map_pt entries;
+    log_helper_pt* loghelper;
+
+    celix_thread_mutex_t pollerLock;
+    celix_thread_t pollerThread;
+
+    unsigned int poll_interval;
+    volatile bool running;
+};
+
 typedef struct endpoint_discovery_poller *endpoint_discovery_poller_pt;
 
 celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_context_pt context,
endpoint_discovery_poller_pt *poller);

Modified: celix/trunk/remote_services/discovery/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/discovery.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery/private/src/discovery.c Tue Dec  2 18:33:43 2014
@@ -40,7 +40,8 @@
 #include "service_reference.h"
 #include "service_registration.h"
 #include "remote_constants.h"
-#include "celix_log.h"
+#include "log_helper.h"
+#include "log_service.h"
 #include "discovery.h"
 #include "discovery_impl.h"
 #include "endpoint_discovery_poller.h"
@@ -51,7 +52,7 @@ celix_status_t discovery_endpointAdded(v
 	celix_status_t status = CELIX_SUCCESS;
 	discovery_pt discovery = handle;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Endpoint for %s, with filter \"%s\" added...",
endpoint->service, matchedFilter);
+	logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Endpoint for %s, with filter
\"%s\" added...", endpoint->service, matchedFilter);
 
 	status = endpointDiscoveryServer_addEndpoint(discovery->server, endpoint);
 
@@ -62,7 +63,7 @@ celix_status_t discovery_endpointRemoved
 	celix_status_t status = CELIX_SUCCESS;
 	discovery_pt discovery = handle;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Endpoint for %s, with filter \"%s\" removed...",
endpoint->service, matchedFilter);
+	logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Endpoint for %s, with filter
\"%s\" removed...", endpoint->service, matchedFilter);
 
 	status = endpointDiscoveryServer_removeEndpoint(discovery->server, endpoint);
 
@@ -90,7 +91,7 @@ celix_status_t discovery_endpointListene
 	filter_pt filter = filter_create(scope);
 
 	if (discoveryListener != NULL && strcmp(discoveryListener, "true") == 0) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "EndpointListener Ignored - Discovery listener");
+		logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "EndpointListener Ignored
- Discovery listener");
 	} else {
 		celixThreadMutex_lock(&discovery->discoveredServicesMutex);
 
@@ -103,7 +104,7 @@ celix_status_t discovery_endpointListene
 			if (matchResult) {
 				endpoint_listener_pt listener = service;
 
-				fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "EndpointListener Added - Add Scope");
+				logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "EndpointListener Added
- Add Scope");
 
 				listener->endpointAdded(listener, endpoint, NULL);
 			}
@@ -141,7 +142,7 @@ celix_status_t discovery_endpointListene
 
 	if (discovery->listenerReferences != NULL) {
 		if (hashMap_remove(discovery->listenerReferences, reference)) {
-			fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "EndpointListener Removed");
+			logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "EndpointListener Removed");
 		}
 	}
 
@@ -174,11 +175,11 @@ celix_status_t discovery_informEndpointL
 			if (matchResult) {
 				bundleContext_getService(discovery->context, reference, (void**) &listener);
 				if (endpointAdded) {
-					fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Adding service (%s)", endpoint->service);
+					logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Adding service (%s)",
endpoint->service);
 
 					listener->endpointAdded(listener->handle, endpoint, scope);
 				} else {
-					fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Removing service (%s)", endpoint->service);
+					logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Removing service (%s)",
endpoint->service);
 
 					listener->endpointRemoved(listener->handle, endpoint, scope);
 				}

Modified: celix/trunk/remote_services/discovery/private/src/discovery_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/discovery_activator.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/discovery_activator.c (original)
+++ celix/trunk/remote_services/discovery/private/src/discovery_activator.c Tue Dec  2 18:33:43
2014
@@ -32,7 +32,8 @@
 #include "service_registration.h"
 #include "constants.h"
 
-#include "celix_log.h"
+#include "log_helper.h"
+#include "log_service.h"
 #include "discovery.h"
 #include "endpoint_listener.h"
 #include "remote_constants.h"
@@ -40,6 +41,7 @@
 struct activator {
 	bundle_context_pt context;
 	discovery_pt discovery;
+	log_helper_pt loghelper;
 
 	service_tracker_pt endpointListenerTracker;
 	service_registration_pt endpointListenerService;
@@ -78,6 +80,8 @@ celix_status_t bundleActivator_create(bu
 	activator->endpointListenerTracker = NULL;
 	activator->endpointListenerService = NULL;
 
+	logHelper_create(context, &activator->loghelper);
+
 	status = bundleActivator_createEPLTracker(activator, &activator->endpointListenerTracker);
 
 	*userData = activator;
@@ -88,11 +92,13 @@ celix_status_t bundleActivator_create(bu
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator *activator = userData;
-
 	char *uuid = NULL;
+
+	logHelper_start(activator->loghelper);
+
 	status = bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
 	if (!uuid) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "no framework UUID defined?!");
+		logHelper_log(activator->loghelper, OSGI_LOGSERVICE_DEBUG, "no framework UUID defined?!");
 		return CELIX_ILLEGAL_STATE;
 	}
 
@@ -105,7 +111,7 @@ celix_status_t bundleActivator_start(voi
 	sprintf(scope, "(&(%s=*)(%s=%s))", OSGI_FRAMEWORK_OBJECTCLASS, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID,
uuid);
 	scope[len] = 0;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "using scope %s.", scope);
+	logHelper_log(activator->loghelper, OSGI_LOGSERVICE_DEBUG, "using scope %s.", scope);
 
 	endpoint_listener_pt endpointListener = malloc(sizeof(struct endpoint_listener));
 	if (!endpointListener) {
@@ -146,6 +152,8 @@ celix_status_t bundleActivator_stop(void
 
 	status = discovery_stop(activator->discovery);
 
+	logHelper_stop(activator->loghelper);
+
 	return status;
 }
 
@@ -159,6 +167,9 @@ celix_status_t bundleActivator_destroy(v
 
 	status = discovery_destroy(activator->discovery);
 
+	logHelper_destroy(&activator->loghelper);
+
+	activator->loghelper = NULL;
 	activator->endpointListenerTracker = NULL;
 	activator->endpointListenerService = NULL;
 	activator->discovery = NULL;

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_descriptor_reader.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_descriptor_reader.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_descriptor_reader.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_descriptor_reader.c Tue Dec
 2 18:33:43 2014
@@ -28,23 +28,26 @@
 #include <string.h>
 #include <libxml/xmlreader.h>
 
-#include "celix_log.h"
+#include "log_helper.h"
+#include "log_service.h"
 #include "constants.h"
 #include "remote_constants.h"
 
 #include "endpoint_description.h"
 #include "endpoint_descriptor_common.h"
 #include "endpoint_descriptor_reader.h"
+#include "endpoint_discovery_poller.h"
 #include "properties.h"
 #include "utils.h"
 
 struct endpoint_descriptor_reader {
     xmlTextReaderPtr reader;
+    log_helper_pt* loghelper;
 };
 
 static valueType valueTypeFromString(char *name);
 
-celix_status_t endpointDescriptorReader_create(endpoint_descriptor_reader_pt *reader) {
+celix_status_t endpointDescriptorReader_create(endpoint_discovery_poller_pt poller, endpoint_descriptor_reader_pt
*reader) {
     celix_status_t status = CELIX_SUCCESS;
 
     *reader = malloc(sizeof(**reader));
@@ -52,6 +55,7 @@ celix_status_t endpointDescriptorReader_
         status = CELIX_ENOMEM;
     } else {
         (*reader)->reader = NULL;
+        (*reader)->loghelper = poller->loghelper;
     }
 
     return status;
@@ -60,6 +64,8 @@ celix_status_t endpointDescriptorReader_
 celix_status_t endpointDescriptorReader_destroy(endpoint_descriptor_reader_pt reader) {
     celix_status_t status = CELIX_SUCCESS;
 
+    reader->loghelper = NULL;
+
     free(reader);
 
     return status;
@@ -164,7 +170,7 @@ celix_status_t endpointDescriptorReader_
 
                         if (propertyValue != NULL) {
                         	if (propertyType != VALUE_TYPE_STRING && strcmp(OSGI_RSA_ENDPOINT_SERVICE_ID,
(char*) propertyName)) {
-                        		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "ENDPOINT_DESCRIPTOR_READER:
Only single-valued string supported for %s\n", propertyName);
+                        		logHelper_log(*reader->loghelper, OSGI_LOGSERVICE_WARNING, "ENDPOINT_DESCRIPTOR_READER:
Only single-valued string supported for %s\n", propertyName);
                         	}
 
                         	endpointDescriptorReader_addSingleValuedProperty(endpointProperties,
propertyName, propertyValue);
@@ -209,7 +215,7 @@ celix_status_t endpointDescriptorReader_
                     }
                     else if (propertyValue != NULL) {
                     	if (propertyType != VALUE_TYPE_STRING) {
-                    		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "ENDPOINT_DESCRIPTOR_READER:
Only string support for %s\n", propertyName);
+                    		logHelper_log(*reader->loghelper, OSGI_LOGSERVICE_WARNING, "ENDPOINT_DESCRIPTOR_READER:
Only string support for %s\n", propertyName);
                     	}
                     	endpointDescriptorReader_addSingleValuedProperty(endpointProperties,
propertyName, propertyValue);
 

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c Tue Dec
 2 18:33:43 2014
@@ -31,9 +31,10 @@
 
 #include <curl/curl.h>
 
+#include "bundle_context.h"
 #include "hash_map.h"
 #include "array_list.h"
-#include "celix_log.h"
+#include "log_helper.h"
 #include "celix_threads.h"
 #include "utils.h"
 
@@ -43,16 +44,6 @@
 #include "endpoint_discovery_poller.h"
 #include "endpoint_descriptor_reader.h"
 
-struct endpoint_discovery_poller {
-    discovery_pt discovery;
-    hash_map_pt entries;
-
-    celix_thread_mutex_t pollerLock;
-    celix_thread_t pollerThread;
-
-    unsigned int poll_interval;
-    volatile bool running;
-};
 
 #define DISCOVERY_POLL_INTERVAL "DISCOVERY_CFG_POLL_INTERVAL"
 #define DEFAULT_POLL_INTERVAL "10"
@@ -72,6 +63,8 @@ celix_status_t endpointDiscoveryPoller_c
         return CELIX_ENOMEM;
     }
 
+    (*poller)->loghelper = &discovery->loghelper;
+
 	status = celixThreadMutex_create(&(*poller)->pollerLock, NULL);
 	if (status != CELIX_SUCCESS) {
 		return status;
@@ -141,6 +134,8 @@ celix_status_t endpointDiscoveryPoller_d
 
     status = celixThreadMutex_unlock(&poller->pollerLock);
 
+    poller->loghelper = NULL;
+
     free(poller);
 
 	return status;
@@ -206,7 +201,7 @@ static void *endpointDiscoveryPoller_pol
 
         celix_status_t status = celixThreadMutex_lock(&poller->pollerLock);
         if (status != CELIX_SUCCESS) {
-        	fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "ENDPOINT_POLLER: failed to obtain lock;
retrying...");
+        	logHelper_log(*poller->loghelper, OSGI_LOGSERVICE_WARNING, "ENDPOINT_POLLER:
failed to obtain lock; retrying...");
         	continue;
         }
 
@@ -250,7 +245,7 @@ static void *endpointDiscoveryPoller_pol
 
 		status = celixThreadMutex_unlock(&poller->pollerLock);
 		if (status != CELIX_SUCCESS) {
-			fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "ENDPOINT_POLLER: failed to release lock; retrying...");
+			logHelper_log(*poller->loghelper, OSGI_LOGSERVICE_WARNING, "ENDPOINT_POLLER: failed
to release lock; retrying...");
 		}
     }
 
@@ -268,7 +263,7 @@ static size_t endpointDiscoveryPoller_wr
 
     mem->memory = realloc(mem->memory, mem->size + realsize + 1);
     if(mem->memory == NULL) {
-    	fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "ENDPOINT_POLLER: not enough memory (realloc
returned NULL)!");
+    	printf("ENDPOINT_POLLER: not enough memory (realloc returned NULL)!");
         return 0;
     }
 
@@ -305,7 +300,7 @@ static celix_status_t endpointDiscoveryP
     if (res == CURLE_OK) {
         endpoint_descriptor_reader_pt reader = NULL;
 
-    	status = endpointDescriptorReader_create(&reader);
+    	status = endpointDescriptorReader_create(poller, &reader);
     	if (status == CELIX_SUCCESS) {
 			status = endpointDescriptorReader_parseDocument(reader, chunk.memory, updatedEndpoints);
     	}
@@ -314,7 +309,7 @@ static celix_status_t endpointDiscoveryP
 			endpointDescriptorReader_destroy(reader);
     	}
     } else {
-    	fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "ENDPOINT_POLLER: unable to read endpoints,
reason: %s", curl_easy_strerror(res));
+    	logHelper_log(*poller->loghelper, OSGI_LOGSERVICE_ERROR, "ENDPOINT_POLLER: unable
to read endpoints, reason: %s", curl_easy_strerror(res));
     }
 
     // clean up endpoints file

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_discovery_server.c Tue Dec
 2 18:33:43 2014
@@ -32,7 +32,8 @@
 #include "civetweb.h"
 #include "celix_errno.h"
 #include "utils.h"
-#include "celix_log.h"
+#include "log_helper.h"
+#include "log_service.h"
 #include "discovery.h"
 #include "discovery_impl.h"
 
@@ -53,6 +54,7 @@ static const char *response_headers =
   "\r\n";
 
 struct endpoint_discovery_server {
+	log_helper_pt* loghelper;
     hash_map_pt entries; // key = endpointId, value = endpoint_descriptor_pt
 
     celix_thread_mutex_t serverLock;
@@ -80,6 +82,8 @@ celix_status_t endpointDiscoveryServer_c
 		return CELIX_ENOMEM;
 	}
 
+	(*server)->loghelper = &discovery->loghelper;
+
 	(*server)->entries = hashMap_create(&utils_stringHash, NULL, &utils_stringEquals,
NULL);
 	if (!(*server)->entries) {
 		return CELIX_ENOMEM;
@@ -96,7 +100,7 @@ celix_status_t endpointDiscoveryServer_c
 
 		bundleContext_getProperty(context, DISCOVERY_SERVER_INTERFACE, &interface);
 		if ((interface != NULL) && (endpointDiscoveryServer_getIpAdress(interface, &ip)
!= CELIX_SUCCESS)) {
-			fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Could not retrieve IP adress for interface
%s", interface);
+			logHelper_log(*(*server)->loghelper, OSGI_LOGSERVICE_WARNING, "Could not retrieve IP
adress for interface %s", interface);
 		}
 
 		if (ip == NULL) {
@@ -105,11 +109,11 @@ celix_status_t endpointDiscoveryServer_c
 	}
 
 	if (ip != NULL) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Using %s for service annunciation", ip);
+		logHelper_log(*(*server)->loghelper, OSGI_LOGSERVICE_INFO, "Using %s for service annunciation",
ip);
 		(*server)->ip = strdup(ip);
 	}
 	else {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "No IP address for service annunciation set.
Using %s", DEFAULT_SERVER_IP);
+		logHelper_log(*(*server)->loghelper, OSGI_LOGSERVICE_WARNING, "No IP address for service
annunciation set. Using %s", DEFAULT_SERVER_IP);
 		(*server)->ip = (char*) DEFAULT_SERVER_IP;
 	}
 
@@ -142,7 +146,7 @@ celix_status_t endpointDiscoveryServer_c
 
 		if ((*server)->ctx != NULL)
 		{
-			fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Starting discovery server on port %s...", port);
+			logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Starting discovery server
on port %s...", port);
 		}
 		else {
 			errno = 0;
@@ -157,7 +161,7 @@ celix_status_t endpointDiscoveryServer_c
 	        port_counter++;
 			snprintf(&newPort[0], 10,  "%d", (currentPort+1));
 
-			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Error while starting discovery server on port
%s - retrying on port %s...", port, newPort);
+			logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_ERROR, "Error while starting discovery
server on port %s - retrying on port %s...", port, newPort);
 			port = newPort;
 
 		}
@@ -218,7 +222,7 @@ celix_status_t endpointDiscoveryServer_a
 	char* endpointId = strdup(endpoint->id);
 	endpoint_description_pt cur_value = hashMap_get(server->entries, endpointId);
 	if (!cur_value) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "exposing new endpoint \"%s\"...", endpointId);
+		logHelper_log(*server->loghelper, OSGI_LOGSERVICE_INFO, "exposing new endpoint \"%s\"...",
endpointId);
 
 		hashMap_put(server->entries, endpointId, endpoint);
 	}
@@ -243,7 +247,7 @@ celix_status_t endpointDiscoveryServer_r
 	if (entry) {
 		char* key = hashMapEntry_getKey(entry);
 
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "removing endpoint \"%s\"...\n", key);
+		logHelper_log(*server->loghelper, OSGI_LOGSERVICE_INFO, "removing endpoint \"%s\"...\n",
key);
 
 		hashMap_remove(server->entries, key);
 

Modified: celix/trunk/remote_services/discovery_configured/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/CMakeLists.txt?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/CMakeLists.txt (original)
+++ celix/trunk/remote_services/discovery_configured/CMakeLists.txt Tue Dec  2 18:33:43 2014
@@ -27,6 +27,7 @@ include_directories("${PROJECT_SOURCE_DI
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery_configured/private/include")
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
 include_directories(private/include)
 
 SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_rsa_discovery_configured")
@@ -43,6 +44,8 @@ bundle(discovery_configured SOURCES
 	${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
     ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
     ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
+    
+    ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
 )
     
 install_bundle(discovery_configured)

Modified: celix/trunk/remote_services/discovery_configured/private/include/discovery_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/include/discovery_impl.h?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/include/discovery_impl.h (original)
+++ celix/trunk/remote_services/discovery_configured/private/include/discovery_impl.h Tue
Dec  2 18:33:43 2014
@@ -36,6 +36,7 @@
 #include "endpoint_discovery_poller.h"
 #include "endpoint_discovery_server.h"
 
+#include "log_helper.h"
 
 #define DEFAULT_SERVER_IP 	"127.0.0.1"
 #define DEFAULT_SERVER_PORT "9999"
@@ -54,6 +55,8 @@ struct discovery {
 
 	endpoint_discovery_poller_pt poller;
 	endpoint_discovery_server_pt server;
+
+	log_helper_pt loghelper;
 };
 
 #endif /* DISCOVERY_IMPL_H_ */

Modified: celix/trunk/remote_services/discovery_configured/private/src/discovery_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_configured/private/src/discovery_impl.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_configured/private/src/discovery_impl.c (original)
+++ celix/trunk/remote_services/discovery_configured/private/src/discovery_impl.c Tue Dec
 2 18:33:43 2014
@@ -40,7 +40,7 @@
 #include "service_reference.h"
 #include "service_registration.h"
 #include "remote_constants.h"
-#include "celix_log.h"
+#include "log_helper.h"
 
 #include "discovery.h"
 #include "discovery_impl.h"
@@ -54,18 +54,21 @@ celix_status_t discovery_create(bundle_c
 
 	*discovery = malloc(sizeof(struct discovery));
 	if (!*discovery) {
-		return CELIX_ENOMEM;
+		status = CELIX_ENOMEM;
 	}
+	else {
+		(*discovery)->context = context;
+		(*discovery)->poller = NULL;
+		(*discovery)->server = NULL;
 
-	(*discovery)->context = context;
-	(*discovery)->poller = NULL;
-	(*discovery)->server = NULL;
+		(*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2,
NULL);
+		(*discovery)->discoveredServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 
-	(*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2,
NULL);
-	(*discovery)->discoveredServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
+		status = celixThreadMutex_create(&(*discovery)->listenerReferencesMutex, NULL);
+		status = celixThreadMutex_create(&(*discovery)->discoveredServicesMutex, NULL);
 
-	status = celixThreadMutex_create(&(*discovery)->listenerReferencesMutex, NULL);
-	status = celixThreadMutex_create(&(*discovery)->discoveredServicesMutex, NULL);
+		logHelper_create(context, &(*discovery)->loghelper);
+	}
 
 	return status;
 }
@@ -73,6 +76,8 @@ celix_status_t discovery_create(bundle_c
 celix_status_t discovery_start(discovery_pt discovery) {
     celix_status_t status = CELIX_SUCCESS;
 
+	logHelper_start(discovery->loghelper);
+
     status = endpointDiscoveryPoller_create(discovery, discovery->context, &discovery->poller);
     if (status != CELIX_SUCCESS) {
     	return CELIX_BUNDLE_EXCEPTION;
@@ -114,6 +119,8 @@ celix_status_t discovery_stop(discovery_
 
 	celixThreadMutex_unlock(&discovery->discoveredServicesMutex);
 
+	logHelper_stop(discovery->loghelper);
+
 	return status;
 }
 
@@ -142,6 +149,8 @@ celix_status_t discovery_destroy(discove
 
 	celixThreadMutex_destroy(&discovery->listenerReferencesMutex);
 
+	logHelper_destroy(&discovery->loghelper);
+
 	free(discovery);
 
 	return status;

Modified: celix/trunk/remote_services/discovery_etcd/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/CMakeLists.txt?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_etcd/CMakeLists.txt (original)
+++ celix/trunk/remote_services/discovery_etcd/CMakeLists.txt Tue Dec  2 18:33:43 2014
@@ -31,6 +31,7 @@ if (RSA_BUNDLES_DISCOVERY_ETCD)
 	include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery_etcd/private/include")
 	include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
 	include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
+	include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
 	include_directories("private/include")
 
 	SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_rsa_discovery_etcd")
@@ -50,6 +51,8 @@ if (RSA_BUNDLES_DISCOVERY_ETCD)
 		${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
 	    ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
 	    ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
+	    
+	    ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
 	)
 
 	install_bundle(discovery_etcd)

Modified: celix/trunk/remote_services/discovery_etcd/private/include/discovery_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/include/discovery_impl.h?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_etcd/private/include/discovery_impl.h (original)
+++ celix/trunk/remote_services/discovery_etcd/private/include/discovery_impl.h Tue Dec  2
18:33:43 2014
@@ -60,6 +60,8 @@ struct discovery {
 	etcd_watcher_pt watcher;
 	endpoint_discovery_poller_pt poller;
 	endpoint_discovery_server_pt server;
+
+	log_helper_pt loghelper;
 };
 
 #endif /* DISCOVERY_H_ */

Modified: celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c?rev=1642985&r1=1642984&r2=1642985&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c (original)
+++ celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c Tue Dec  2 18:33:43
2014
@@ -27,7 +27,8 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#include "celix_log.h"
+#include "log_helper.h"
+#include "log_service.h"
 #include "constants.h"
 #include "discovery.h"
 #include "discovery_impl.h"
@@ -39,6 +40,7 @@
 
 struct etcd_watcher {
     discovery_pt discovery;
+    log_helper_pt* loghelper;
 
 	celix_thread_mutex_t watcherLock;
 	celix_thread_t watcherThread;
@@ -188,7 +190,7 @@ static celix_status_t etcdWatcher_addOwn
 		etcd_set(localNodePath, endpoints, ttl, false);
 	}
 	else if (etcd_set(localNodePath, endpoints, ttl, true) == false)  {
-        fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot register local discovery");
+		logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot register local discovery");
     }
     else {
         status = CELIX_SUCCESS;
@@ -228,7 +230,7 @@ static void* etcdWatcher_run(void* data)
 			} else if (strcmp(action, "update") == 0) {
 				// TODO
 			} else {
-				fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Unexpected action: %s", action);
+				logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_INFO, "Unexpected action: %s",
action);
 			}
 			highestModified++;
 		}
@@ -260,6 +262,7 @@ celix_status_t etcdWatcher_create(discov
 		return CELIX_BUNDLE_EXCEPTION;
 	}
 
+
 	(*watcher) = calloc(1, sizeof(struct etcd_watcher));
 	if (!watcher) {
 		return CELIX_ENOMEM;
@@ -267,6 +270,7 @@ celix_status_t etcdWatcher_create(discov
 	else
 	{
 		(*watcher)->discovery = discovery;
+		(*watcher)->loghelper = discovery->loghelper;
 	}
 
 	if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_IP, &etcd_server) != CELIX_SUCCESS)
|| !etcd_server) {
@@ -327,9 +331,11 @@ celix_status_t etcdWatcher_destroy(etcd_
 
 	if (status != CELIX_SUCCESS || etcd_del(localNodePath) == false)
 	{
-		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot remove local discovery registration.");
+		logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot remove local discovery
registration.");
 	}
 
+	watcher->loghelper = NULL;
+
 	free(watcher);
 
 	return status;



Mime
View raw message