celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1645345 - in /celix/trunk/device_access/device_access: CMakeLists.txt private/src/activator.c private/src/device_manager.c private/src/driver_matcher.c
Date Sat, 13 Dec 2014 19:02:05 GMT
Author: bpetri
Date: Sat Dec 13 19:02:05 2014
New Revision: 1645345

URL: http://svn.apache.org/r1645345
Log:
CELIX-182: replace device_access fw_log calls w/ loghelper

Modified:
    celix/trunk/device_access/device_access/CMakeLists.txt
    celix/trunk/device_access/device_access/private/src/activator.c
    celix/trunk/device_access/device_access/private/src/device_manager.c
    celix/trunk/device_access/device_access/private/src/driver_matcher.c

Modified: celix/trunk/device_access/device_access/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/CMakeLists.txt?rev=1645345&r1=1645344&r2=1645345&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/CMakeLists.txt (original)
+++ celix/trunk/device_access/device_access/CMakeLists.txt Sat Dec 13 19:02:05 2014
@@ -28,6 +28,8 @@ bundle(device_manager SOURCES
 	private/src/driver_loader
 	private/src/driver_matcher
     
+    ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+    
     private/include/device_manager.h
     private/include/driver_attributes.h
     private/include/driver_loader.h
@@ -45,6 +47,7 @@ install_bundle(device_manager
 
 include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
 
 include_directories("public/include")
 include_directories("private/include")

Modified: celix/trunk/device_access/device_access/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/private/src/activator.c?rev=1645345&r1=1645344&r2=1645345&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/private/src/activator.c (original)
+++ celix/trunk/device_access/device_access/private/src/activator.c Sat Dec 13 19:02:05 2014
@@ -33,8 +33,10 @@
 
 #include "driver_locator.h"
 #include "device_manager.h"
+#include "log_helper.h"
 
 struct device_manager_bundle_instance {
+	log_helper_pt loghelper;
 	bundle_context_pt context;
 	apr_pool_t *pool;
 	device_manager_pt deviceManager;
@@ -72,6 +74,9 @@ celix_status_t bundleActivator_create(bu
 			(*userData) = bi;
 			bi->context = context;
 			bi->pool = pool;
+
+			logHelper_create(context, &bi->loghelper);
+
 			status = deviceManager_create(pool, context, &bi->deviceManager);
 		}
 	}
@@ -82,6 +87,9 @@ celix_status_t bundleActivator_start(voi
 	celix_status_t status = CELIX_SUCCESS;
 	device_manager_bundle_instance_pt bundleData = userData;
 	apr_pool_t *pool;
+
+	logHelper_start(bundleData->loghelper);
+
 	status = bundleContext_getMemoryPool(context, &pool);
 	if (status == CELIX_SUCCESS) {
 		status = deviceManagerBundle_createDriverLocatorTracker(bundleData);
@@ -103,10 +111,11 @@ celix_status_t bundleActivator_start(voi
 	}
 
 	if (status != CELIX_SUCCESS) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "DEVICE_MANAGER: Error while starting bundle got
error num %d", status);
+		logHelper_log(bundleData->loghelper, OSGI_FRAMEWORK_LOG_ERROR, "DEVICE_MANAGER: Error
while starting bundle got error num %d", status);
 	}
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "DEVICE_MANAGER: Started");
+	logHelper_log(bundleData->loghelper, OSGI_FRAMEWORK_LOG_INFO, "DEVICE_MANAGER: Started");
+
 	return status;
 }
 
@@ -180,6 +189,9 @@ celix_status_t bundleActivator_stop(void
 			status = serviceTracker_close(bundleData->deviceTracker);
 		}
 	}
+
+	logHelper_stop(bundleData->loghelper);
+
 	return status;
 }
 
@@ -187,5 +199,8 @@ celix_status_t bundleActivator_destroy(v
 	celix_status_t status = CELIX_SUCCESS;
 	device_manager_bundle_instance_pt bundleData = userData;
 	status = deviceManager_destroy(bundleData->deviceManager);
+
+	logHelper_destroy(&bundleData->loghelper);
+
 	return status;
 }

Modified: celix/trunk/device_access/device_access/private/src/device_manager.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/private/src/device_manager.c?rev=1645345&r1=1645344&r2=1645345&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/private/src/device_manager.c (original)
+++ celix/trunk/device_access/device_access/private/src/device_manager.c Sat Dec 13 19:02:05
2014
@@ -34,6 +34,9 @@
 #include "driver_loader.h"
 #include "driver.h"
 #include "device.h"
+#include "log_helper.h"
+#include "log_service.h"
+
 
 #include <bundle.h>
 #include <module.h>
@@ -48,6 +51,7 @@ struct device_manager {
 	hash_map_pt drivers;
 	array_list_pt locators;
 	driver_selector_service_pt selector;
+	log_helper_pt loghelper;
 };
 
 static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt
ref, void *service);
@@ -70,17 +74,25 @@ celix_status_t deviceManager_create(apr_
 
 		(*manager)->devices = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2,
NULL);
 		(*manager)->drivers = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2,
NULL);
+
 		status = arrayList_create(&(*manager)->locators);
+
+		if(logHelper_create(context, &(*manager)->loghelper) == CELIX_SUCCESS) {
+			logHelper_start((*manager)->loghelper);
+		}
 	}
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Initialized");
+	logHelper_log((*manager)->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Initialized");
 	return status;
 }
 
 celix_status_t deviceManager_destroy(device_manager_pt manager) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "DEVICE_MANAGER: Stop");
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Stop");
+
+	logHelper_stop(manager->loghelper);
+	logHelper_destroy(&manager->loghelper);
 	hashMap_destroy(manager->devices, false, false);
 	hashMap_destroy(manager->drivers, false, false);
 	arrayList_destroy(manager->locators);
@@ -89,48 +101,50 @@ celix_status_t deviceManager_destroy(dev
 }
 
 celix_status_t deviceManager_selectorAdded(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Add selector");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add selector");
+
 	manager->selector = (driver_selector_service_pt) service;
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_selectorModified(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Modify selector");
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify selector");
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_selectorRemoved(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Remove selector");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove selector");
 	manager->selector = NULL;
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void *
service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Add locator");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add locator");
 	arrayList_add(manager->locators, service);
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Modify locator");
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify locator");
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Remove locator");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove locator");
 	arrayList_removeElement(manager->locators, service);
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void *
service) {
 	celix_status_t status = CELIX_SUCCESS;
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Add device");
 	device_manager_pt manager = handle;
-
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add device");
 	status = deviceManager_attachAlgorithm(manager, ref, service);
 
 	return status;
@@ -226,7 +240,7 @@ celix_status_t deviceManager_matchAttach
 
 	for (i = 0; i < arrayList_size(driverIds); i++) {
 		char *id = arrayList_get(driverIds, i);
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "DEVICE_MANAGER: Driver found: %s", id);
+		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Driver found:
%s", id);
 	}
 
 	status = driverLoader_loadDrivers(loader, attachPool, manager->locators, driverIds, &references);
@@ -248,7 +262,7 @@ celix_status_t deviceManager_matchAttach
 				int match = 0;
 				celix_status_t substatus = driverAttributes_match(attributes, reference, &match);
 				if (substatus == CELIX_SUCCESS) {
-					fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "DEVICE_MANAGER: Found match: %d", match);
+					logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Found match:
%d", match);
 					if (match <= OSGI_DEVICEACCESS_DEVICE_MATCH_NONE) {
 						continue;
 					}
@@ -308,16 +322,16 @@ celix_status_t deviceManager_noDriverFou
 }
 
 celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Modify device");
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify device");
 	// #TODO the device properties could be changed
-	//device_manager_pt manager = handle;
 	//hashMap_put(manager->devices, ref, service);
 	return CELIX_SUCCESS;
 }
 
 celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Remove device");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove device");
 	hashMap_remove(manager->devices, ref);
 	return CELIX_SUCCESS;
 }
@@ -325,8 +339,8 @@ celix_status_t deviceManager_deviceRemov
 celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void *
service) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Add driver");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add driver");
 	apr_pool_t *pool = NULL;
 	driver_attributes_pt attributes = NULL;
 
@@ -341,7 +355,8 @@ celix_status_t deviceManager_driverAdded
 }
 
 celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Modify driver");
+	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify driver");
 	// #TODO the driver properties could be changed?
 	return CELIX_SUCCESS;
 }
@@ -349,8 +364,9 @@ celix_status_t deviceManager_driverModif
 celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void
* service) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Remove driver");
 	device_manager_pt manager = handle;
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove driver");
+
 	hashMap_remove(manager->drivers, ref);
 
 	apr_pool_t *idleCheckPool;
@@ -374,7 +390,7 @@ celix_status_t deviceManager_driverRemov
 					if (forStatus == CELIX_SUCCESS) {
 						forStatus = module_getSymbolicName(module, &bsn);
 						if (forStatus == CELIX_SUCCESS) {
-							fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: IDLE: %s", bsn);
+							logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: IDLE:
%s", bsn);
 							// #TODO attachDriver (idle device)
 							// #TODO this can result in a loop?
 							//		Locate and install a driver
@@ -429,7 +445,7 @@ celix_status_t deviceManager_getIdleDevi
 				if (substatus == CELIX_SUCCESS) {
 					substatus = module_getSymbolicName(module, &bsn);
 					if (substatus == CELIX_SUCCESS) {
-						fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
+						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check
idle device: %s", bsn);
 						array_list_pt bundles = NULL;
 						substatus = serviceReference_getUsingBundles(ref, &bundles);
 						if (substatus == CELIX_SUCCESS) {
@@ -446,7 +462,7 @@ celix_status_t deviceManager_getIdleDevi
 										bundle_getCurrentModule(bundle, &module);
 										module_getSymbolicName(module, &bsn);
 
-										fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Not idle, used by driver:
%s", bsn);
+										logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not
idle, used by driver: %s", bsn);
 
 										inUse = true;
 										break;
@@ -493,7 +509,7 @@ celix_status_t deviceManager_getIdleDevi
 			substatus = DO_IF_SUCCESS(substatus, serviceReference_getUsingBundles(ref, &bundles));
 
 			if (substatus == CELIX_SUCCESS) {
-				fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
+				logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle
device: %s", bsn);
 				bool inUse = false;
 				int i;
 				for (i = 0; i < arrayList_size(bundles); i++) {
@@ -507,7 +523,7 @@ celix_status_t deviceManager_getIdleDevi
 							bundle_getCurrentModule(bundle, &module);
 							module_getSymbolicName(module, &bsn);
 
-							fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DEVICE_MANAGER: Not idle, used by driver:
%s", bsn);
+							logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle,
used by driver: %s", bsn);
 
 							inUse = true;
 							break;

Modified: celix/trunk/device_access/device_access/private/src/driver_matcher.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/private/src/driver_matcher.c?rev=1645345&r1=1645344&r2=1645345&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/private/src/driver_matcher.c (original)
+++ celix/trunk/device_access/device_access/private/src/driver_matcher.c Sat Dec 13 19:02:05
2014
@@ -29,18 +29,22 @@
 #include "constants.h"
 
 #include "driver_matcher.h"
+#include "log_helper.h"
+#include "log_service.h"
+
 
 struct driver_matcher {
 	apr_pool_t *pool;
 	hash_map_pt attributes;
-	 array_list_pt matches;
+	array_list_pt matches;
+	log_helper_pt loghelper;
 
-	 bundle_context_pt context;
+	bundle_context_pt context;
 };
 
 typedef struct match_key {
 	int matchValue;
-} *match_key_t;
+}*match_key_t;
 
 static apr_status_t driverMatcher_destroy(void *matcherP);
 static celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt
*attributesV);
@@ -71,6 +75,11 @@ celix_status_t driverMatcher_create(apr_
 		(*matcher)->attributes = hashMap_create(driverMatcher_matchKeyHash, NULL, driverMatcher_matchKeyEquals,
NULL);
 
 		arrayList_create(&(*matcher)->matches);
+
+		if(logHelper_create(context, &(*matcher)->loghelper) == CELIX_SUCCESS) {
+			logHelper_start((*matcher)->loghelper);
+		}
+
 	}
 
 	return status;
@@ -88,6 +97,10 @@ apr_status_t driverMatcher_destroy(void
 	}
 	hashMapIterator_destroy(iter);
 	hashMap_destroy(matcher->attributes, false, false);
+
+	logHelper_stop(matcher->loghelper);
+	logHelper_destroy(&matcher->loghelper);
+
 	return APR_SUCCESS;
 }
 
@@ -196,37 +209,42 @@ celix_status_t driverMatcher_getBestMatc
 			celix_status_t substatus = driverAttributes_getReference(attributes, &reference);
 			if (substatus == CELIX_SUCCESS) {
 				if (best != NULL) {
-					fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DRIVER_MATCHER: Compare ranking");
 					char *rank1Str, *rank2Str;
 					int rank1, rank2;
-                    rank1Str = "0";
-                    rank2Str = "0";
-                    serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING,
&rank1Str);
-                    serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING,
&rank2Str);
-
-                    rank1 = atoi(rank1Str);
-                    rank2 = atoi(rank2Str);
-
-                    if (rank1 != rank2) {
-                        if (rank1 > rank2) {
-                            best = reference;
-                        }
-                    } else {
-                        fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DRIVER_MATCHER: Compare
id's");
-                        char *id1Str, *id2Str;
-                        long id1, id2;
-
-                        id1Str = NULL;
-                        id2Str = NULL;
-                        serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID,
&id1Str);
-                        serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID,
&id2Str);
-
-                        id1 = atol(id1Str);
-                        id2 = atol(id2Str);
-
-                        if (id1 < id2) {
-                            best = reference;
-                        }
+
+					rank1Str = "0";
+					rank2Str = "0";
+
+					logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare
ranking");
+
+					serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str);
+					serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str);
+
+					rank1 = atoi(rank1Str);
+					rank2 = atoi(rank2Str);
+
+					if (rank1 != rank2) {
+						if (rank1 > rank2) {
+							best = reference;
+						}
+					} else {
+						char *id1Str, *id2Str;
+						long id1, id2;
+
+						id1Str = NULL;
+						id2Str = NULL;
+
+						logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare
id's");
+
+						serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id1Str);
+						serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id2Str);
+
+						id1 = atol(id1Str);
+						id2 = atol(id2Str);
+
+						if (id1 < id2) {
+							best = reference;
+						}
 					}
 				} else {
 					best = reference;



Mime
View raw message