diff --git a/bundles/logging/CMakeLists.txt b/bundles/logging/CMakeLists.txt index 1d3604bb0..abe71980f 100644 --- a/bundles/logging/CMakeLists.txt +++ b/bundles/logging/CMakeLists.txt @@ -21,12 +21,6 @@ add_subdirectory(log_helper) celix_subproject(LOG_SERVICE "Option to enable building the Log Service bundles" ON) if (LOG_SERVICE) - #Version 2 API (deprecated) - if (CELIX_INSTALL_DEPRECATED_API) - add_subdirectory(log_service_v2) - endif () - - #Version 3 API add_subdirectory(log_admin) add_subdirectory(log_writers) endif () diff --git a/bundles/logging/log_helper/CMakeLists.txt b/bundles/logging/log_helper/CMakeLists.txt index 2fa17133d..50fd467a5 100644 --- a/bundles/logging/log_helper/CMakeLists.txt +++ b/bundles/logging/log_helper/CMakeLists.txt @@ -17,26 +17,13 @@ celix_subproject(LOG_HELPER "Option to enable building the log helper library" ON) if (LOG_HELPER) - if (CELIX_INSTALL_DEPRECATED_API) - set(SOURCES src/celix_log_helper.c src/log_helper.c) - else () - set(SOURCES src/celix_log_helper.c) - endif () - - add_library(log_helper STATIC ${SOURCES}) + add_library(log_helper STATIC src/celix_log_helper.c) set_target_properties(log_helper PROPERTIES OUTPUT_NAME "celix_log_utils") target_include_directories(log_helper PUBLIC $ ) target_link_libraries(log_helper PUBLIC Celix::log_service_api Celix::framework PRIVATE Celix::utils) - if (CELIX_INSTALL_DEPRECATED_API) - target_include_directories(log_helper PUBLIC - $ - ) - install(DIRECTORY include_v1/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper) - endif () - install(TARGETS log_helper EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT logging INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper COMPONENT logging) diff --git a/bundles/logging/log_helper/include_v1/log_helper.h b/bundles/logging/log_helper/include_v1/log_helper.h deleted file mode 100644 index 828d37dd8..000000000 --- a/bundles/logging/log_helper/include_v1/log_helper.h +++ /dev/null @@ -1,42 +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. - */ - -#ifndef LOGHELPER_H_ -#define LOGHELPER_H_ - -#include "bundle_context.h" -#include "log_service.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct log_helper log_helper_t; - -celix_status_t logHelper_create(celix_bundle_context_t *context, log_helper_t **log_helper); -celix_status_t logHelper_start(log_helper_t *loghelper); -celix_status_t logHelper_stop(log_helper_t *loghelper); -celix_status_t logHelper_destroy(log_helper_t **loghelper); -celix_status_t logHelper_log(log_helper_t *loghelper, log_level_t level, const char* message, ... ); - -#ifdef __cplusplus -} -#endif - -#endif /* LOGHELPER_H_ */ diff --git a/bundles/logging/log_helper/src/log_helper.c b/bundles/logging/log_helper/src/log_helper.c deleted file mode 100644 index 677564e43..000000000 --- a/bundles/logging/log_helper/src/log_helper.c +++ /dev/null @@ -1,262 +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 Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include -#include - -#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_NAME "LOGHELPER_ENABLE_STDOUT_FALLBACK" -#define LOGHELPER_ENABLE_STDOUT_FALLBACK_DEFAULT true - -#define LOGHELPER_STDOUT_FALLBACK_INCLUDE_DEBUG_NAME "LOGHELPER_STDOUT_FALLBACK_INCLUDE_DEBUG" -#define LOGHELPER_STDOUT_FALLBACK_INCLUDE_DEBUG_DEFAULT false - - -#ifdef __linux__ -//includes for the backtrace function -#include -#include -#include -#endif - -#ifdef __linux__ -static char* logHelper_backtrace(void) { - void *bbuf[64]; - int nrOfTraces = backtrace(bbuf, 64); - char **lines = backtrace_symbols(bbuf, nrOfTraces); - - char *result = NULL; - size_t size = 0; - FILE *os = open_memstream(&result, &size); - fprintf(os, "Backtrace:\n"); - for (int i = 0; i < nrOfTraces; ++i) { - char *line = lines[i]; - fprintf(os, "%s\n", line); - } - free(lines); - fclose(os); - return result; -} -#else -static char* logHelper_backtrace(void) { - return NULL; -} -#endif - -struct log_helper { - celix_bundle_context_t *bundleContext; - celix_service_tracker_t *logServiceTracker; - celix_thread_mutex_t logListLock; - array_list_pt logServices; - bool stdOutFallback; - bool stdOutFallbackIncludeDebug; -}; - -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_t **loghelper) -{ - celix_status_t status = CELIX_SUCCESS; - - (*loghelper) = calloc(1, sizeof(**loghelper)); - - if (!(*loghelper)) - { - status = CELIX_ENOMEM; - } - else - { - (*loghelper)->bundleContext = context; - (*loghelper)->logServiceTracker = NULL; - (*loghelper)->stdOutFallback = false; - - (*loghelper)->stdOutFallback = celix_bundleContext_getPropertyAsBool(context, LOGHELPER_ENABLE_STDOUT_FALLBACK_NAME, LOGHELPER_ENABLE_STDOUT_FALLBACK_DEFAULT); - (*loghelper)->stdOutFallbackIncludeDebug = celix_bundleContext_getPropertyAsBool(context, LOGHELPER_STDOUT_FALLBACK_INCLUDE_DEBUG_NAME, LOGHELPER_STDOUT_FALLBACK_INCLUDE_DEBUG_DEFAULT); - - pthread_mutex_init(&(*loghelper)->logListLock, NULL); - arrayList_create(&(*loghelper)->logServices); - } - - return status; -} - -celix_status_t logHelper_start(log_helper_t *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_t *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_t *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_t *loghelper) { - celix_status_t status; - - status = serviceTracker_close(loghelper->logServiceTracker); - - return status; -} - -celix_status_t logHelper_destroy(log_helper_t **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_t *loghelper, log_level_t level, const 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_t *logService = arrayList_get(loghelper->logServices, i); - if (logService != NULL) { - (logService->log)(logService->logger, level, msg); //TODO add backtrace to msg if the level is ERROR - if (level == OSGI_LOGSERVICE_ERROR) { - char *backtrace = logHelper_backtrace(); - logService->log(logService->logger, level, backtrace); - free(backtrace); - } - logged = true; - } - } - - pthread_mutex_unlock(&loghelper->logListLock); - - if (!logged && loghelper->stdOutFallback) { - char *levelStr = NULL; - bool print = true; - - 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"; - print = loghelper->stdOutFallbackIncludeDebug; - break; - } - - if (print) { - if (level == OSGI_LOGSERVICE_ERROR) { - fprintf(stderr, "%s: %s\n", levelStr, msg); - if (level == OSGI_LOGSERVICE_ERROR) { - char *backtrace = logHelper_backtrace(); - fprintf(stderr, "%s", backtrace); - free(backtrace); - } - } else { - printf("%s: %s\n", levelStr, msg); - } - - } - } - - va_end(listPointer); - - return status; -} diff --git a/bundles/logging/log_service_api/CMakeLists.txt b/bundles/logging/log_service_api/CMakeLists.txt index afd92dc7e..7acb82275 100644 --- a/bundles/logging/log_service_api/CMakeLists.txt +++ b/bundles/logging/log_service_api/CMakeLists.txt @@ -23,14 +23,6 @@ if (LOG_SERVICE_API) ) target_link_libraries(log_service_api INTERFACE Celix::utils) - if (CELIX_INSTALL_DEPRECATED_API) - target_link_libraries(log_service_api INTERFACE Celix::framework) - target_include_directories(log_service_api INTERFACE - $ - ) - install(DIRECTORY include_v2/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service) - endif () - install(TARGETS log_service_api EXPORT celix INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service) diff --git a/bundles/logging/log_service_api/include_v2/log_entry.h b/bundles/logging/log_service_api/include_v2/log_entry.h deleted file mode 100644 index 5e0a4fd35..000000000 --- a/bundles/logging/log_service_api/include_v2/log_entry.h +++ /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. - */ - -#ifndef LOG_ENTRY_H_ -#define LOG_ENTRY_H_ - -#include "log_service.h" - -struct log_entry { - int errorCode; - log_level_t level; - char *message; - time_t time; - - long bundleId; - char* bundleSymbolicName; -}; - -typedef struct log_entry log_entry_t; -typedef struct log_entry *log_entry_pt CELIX_DEPRECATED_ATTR; - -celix_status_t logEntry_create(long bundleId, const char* bundleSymbolicName , service_reference_pt reference, - log_level_t level, char *message, int errorCode, - log_entry_t **entry); -celix_status_t logEntry_destroy(log_entry_t **entry); -celix_status_t logEntry_getBundleSymbolicName(log_entry_t *entry, const char** bundleSymbolicName); -celix_status_t logEntry_getBundleId(log_entry_t *entry, long *bundleId); -celix_status_t logEntry_getErrorCode(log_entry_t *entry, int *errorCode); -celix_status_t logEntry_getLevel(log_entry_t *entry, log_level_t *level); -celix_status_t logEntry_getMessage(log_entry_t *entry, const char** message); -celix_status_t logEntry_getTime(log_entry_t *entry, time_t *time); - -#endif /* LOG_ENTRY_H_ */ diff --git a/bundles/logging/log_service_api/include_v2/log_listener.h b/bundles/logging/log_service_api/include_v2/log_listener.h deleted file mode 100644 index defc03fe7..000000000 --- a/bundles/logging/log_service_api/include_v2/log_listener.h +++ /dev/null @@ -1,35 +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. - */ - -#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)(void *handle, log_entry_t *entry); -}; - -typedef struct log_listener log_listener_t; -typedef struct log_listener *log_listener_pt CELIX_DEPRECATED_ATTR; - - -#endif /* LOG_LISTENER_H_ */ diff --git a/bundles/logging/log_service_api/include_v2/log_reader_service.h b/bundles/logging/log_service_api/include_v2/log_reader_service.h deleted file mode 100644 index e9d3b390b..000000000 --- a/bundles/logging/log_service_api/include_v2/log_reader_service.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. - */ - -#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; - -struct log_reader_service { - log_reader_data_t *reader; - celix_status_t (*getLog)(log_reader_data_t *reader, linked_list_pt *list); - celix_status_t (*addLogListener)(log_reader_data_t *reader, log_listener_t *listener); - celix_status_t (*removeLogListener)(log_reader_data_t *reader, log_listener_t *listener); - celix_status_t (*removeAllLogListener)(log_reader_data_t *reader); -}; - -typedef struct log_reader_service log_reader_service_t; -typedef struct log_reader_service *log_reader_service_pt CELIX_DEPRECATED_ATTR; - -#endif /* LOG_READER_SERVICE_H_ */ diff --git a/bundles/logging/log_service_api/include_v2/log_service.h b/bundles/logging/log_service_api/include_v2/log_service.h deleted file mode 100644 index 2ae497751..000000000 --- a/bundles/logging/log_service_api/include_v2/log_service.h +++ /dev/null @@ -1,51 +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. - */ - -#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_t; - -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_t *logger; - celix_status_t (*log)(log_service_data_t *logger, log_level_t level, char *message); - celix_status_t (*logSr)(log_service_data_t *logger, service_reference_pt reference, log_level_t level, char *message); -}; - -typedef struct log_service log_service_t; -typedef struct log_service *log_service_pt CELIX_DEPRECATED_ATTR; - - - -#endif /* LOG_SERVICE_H_ */ diff --git a/bundles/logging/log_service_v2/CMakeLists.txt b/bundles/logging/log_service_v2/CMakeLists.txt deleted file mode 100644 index 17596fad4..000000000 --- a/bundles/logging/log_service_v2/CMakeLists.txt +++ /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. - -add_celix_bundle(log_service - SYMBOLIC_NAME "apache_celix_log_service" - NAME "Apache Celix Log Service" - FILENAME celix_log_service - GROUP "Celix/Logging" - VERSION "1.1.0" - SOURCES - #v2 api - src/log.c - src/log_entry.c - src/log_factory.c - src/log_service_impl.c - src/log_service_activator.c - src/log_reader_service_impl.c -) -target_include_directories(log_service PRIVATE src) -target_link_libraries(log_service PRIVATE Celix::log_service_api) -celix_deprecated_utils_headers(log_service) -celix_deprecated_framework_headers(log_service) -install_celix_bundle(log_service EXPORT celix COMPONENT logging) - -add_celix_bundle(log_writer_stdout - SYMBOLIC_NAME "apache_celix_log_writer_stdout" - NAME "Apache Celix Log Writer Stdout" - FILENAME celix_log_writer_stdout - GROUP "Celix/Logging" - VERSION "1.1.0" - SOURCES - #v2 api - src/deprecated_log_writer_stdout_activator.c -) -celix_deprecated_utils_headers(log_writer_stdout) -install_celix_bundle(log_writer_stdout EXPORT celix COMPONENT logging) - -#Setup target aliases to match external usage -add_library(Celix::log_service ALIAS log_service) -add_library(Celix::log_writer_stdout ALIAS log_writer_stdout) diff --git a/bundles/logging/log_service_v2/src/deprecated_log_writer_stdout_activator.c b/bundles/logging/log_service_v2/src/deprecated_log_writer_stdout_activator.c deleted file mode 100644 index ed903bf1f..000000000 --- a/bundles/logging/log_service_v2/src/deprecated_log_writer_stdout_activator.c +++ /dev/null @@ -1,37 +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. - */ - -#include "celix_bundle_activator.h" -#include "celix_compiler.h" - -typedef struct deprecated_log_writer_stdout_activator { - //nop -} deprecated_log_writer_stdout_activator_t; - -celix_status_t logWriterStdOut_start(deprecated_log_writer_stdout_activator_t* act CELIX_UNUSED, celix_bundle_context_t* ctx CELIX_UNUSED) { - fprintf(stderr, "Celix::log_writer_stdout bundle is deprecated. Please use Celix::log_admin instead of Celix::log_service and Celix::log_writer_stdout\n"); - return CELIX_SUCCESS; -} - -celix_status_t logWriterStdOut_stop(deprecated_log_writer_stdout_activator_t* act CELIX_UNUSED, celix_bundle_context_t* ctx CELIX_UNUSED) { - //nop; - return CELIX_SUCCESS; -} - -CELIX_GEN_BUNDLE_ACTIVATOR(deprecated_log_writer_stdout_activator_t, logWriterStdOut_start, logWriterStdOut_stop) \ No newline at end of file diff --git a/bundles/logging/log_service_v2/src/log.c b/bundles/logging/log_service_v2/src/log.c deleted file mode 100644 index ebc6405ae..000000000 --- a/bundles/logging/log_service_v2/src/log.c +++ /dev/null @@ -1,340 +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.c - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include - -#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_t *logger); -static celix_status_t log_stopListenerThread(log_t *logger); - - -static void *log_listenerThread(void *data); - -celix_status_t log_create(int max_size, bool store_debug, log_t **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_t *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_t *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_t *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_t *log, log_entry_t *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_t *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_t *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, celix_bundle_event_t *event) { - //deprecated nop - (void)listener; - (void)event; - return CELIX_SUCCESS; -} - -celix_status_t log_frameworkEvent(void *listener, framework_event_pt event) { - //deprecated nop - (void)listener; - (void)event; - return CELIX_SUCCESS; -} - -celix_status_t log_addLogListener(log_t *logger, log_listener_t *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_t *logger, log_listener_t *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_t *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_t *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_t *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_t *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_t *entry = (log_entry_t *) 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_t *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; -} diff --git a/bundles/logging/log_service_v2/src/log.h b/bundles/logging/log_service_v2/src/log.h deleted file mode 100644 index 1da11f33f..000000000 --- a/bundles/logging/log_service_v2/src/log.h +++ /dev/null @@ -1,48 +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.h - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \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_t; - -celix_status_t log_create(int max_size, bool store_debug, log_t **logger); -celix_status_t log_destroy(log_t *logger); -celix_status_t log_addEntry(log_t *log, log_entry_t *entry); -celix_status_t log_getEntries(log_t *log, linked_list_pt *list); - -celix_status_t log_bundleChanged(void *listener, celix_bundle_event_t *event); -celix_status_t log_frameworkEvent(void *listener, framework_event_pt event); - -celix_status_t log_addLogListener(log_t *logger, log_listener_t *listener); -celix_status_t log_removeLogListener(log_t *logger, log_listener_t *listener); -celix_status_t log_removeAllLogListener(log_t *logger); - -#endif /* LOG_H_ */ diff --git a/bundles/logging/log_service_v2/src/log_entry.c b/bundles/logging/log_service_v2/src/log_entry.c deleted file mode 100644 index 284312f82..000000000 --- a/bundles/logging/log_service_v2/src/log_entry.c +++ /dev/null @@ -1,94 +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_entry.c - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include -#include -#include - -#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_t **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_t **entry) { - if (*entry) { - free((*entry)->bundleSymbolicName); - free((*entry)->message); - free(*entry); - *entry = NULL; - } - return CELIX_SUCCESS; -} - -celix_status_t logEntry_getBundleSymbolicName(log_entry_t *entry, const char** bundleSymbolicName) { - *bundleSymbolicName = entry->bundleSymbolicName; - return CELIX_SUCCESS; -} - -celix_status_t logEntry_getBundleId(log_entry_t *entry, long *bundleId) { - *bundleId = entry->bundleId; - return CELIX_SUCCESS; -} - -celix_status_t logEntry_getErrorCode(log_entry_t *entry, int *errorCode) { - *errorCode = entry->errorCode; - return CELIX_SUCCESS; -} - -celix_status_t logEntry_getLevel(log_entry_t *entry, log_level_t *level) { - *level = entry->level; - return CELIX_SUCCESS; -} - -celix_status_t logEntry_getMessage(log_entry_t *entry, const char **message) { - *message = entry->message; - return CELIX_SUCCESS; -} - -celix_status_t logEntry_getTime(log_entry_t *entry, time_t *time) { - *time = entry->time; - return CELIX_SUCCESS; -} diff --git a/bundles/logging/log_service_v2/src/log_factory.c b/bundles/logging/log_service_v2/src/log_factory.c deleted file mode 100644 index ac9be0f2e..000000000 --- a/bundles/logging/log_service_v2/src/log_factory.c +++ /dev/null @@ -1,100 +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_factory.c - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include -#include - - -#include "service_factory.h" -#include "log_factory.h" -#include "log_service_impl.h" - -struct log_service_factory { - log_t *log; -}; - -celix_status_t logFactory_create(log_t *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_t *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_t *log_factory = factory; - log_service_t *log_service = NULL; - log_service_data_t *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, celix_bundle_t *bundle, service_registration_pt registration, void **service) { - log_service_t *log_service = *service; - - logService_destroy(&log_service->logger); - - free(*service); - *service = NULL; - - return CELIX_SUCCESS; -} diff --git a/bundles/logging/log_service_v2/src/log_factory.h b/bundles/logging/log_service_v2/src/log_factory.h deleted file mode 100644 index ae7f66669..000000000 --- a/bundles/logging/log_service_v2/src/log_factory.h +++ /dev/null @@ -1,41 +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_factory.h - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \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_t; -typedef struct log_service_factory *log_service_factory_pt; - -celix_status_t logFactory_create(log_t *log, service_factory_pt *factory); -celix_status_t logFactory_destroy(service_factory_pt *factory); -celix_status_t logFactory_getService(void *factory, celix_bundle_t *bundle, service_registration_pt registration, void **service); -celix_status_t logFactory_ungetService(void *factory, celix_bundle_t *bundle, service_registration_pt registration, void **service); - - -#endif /* LOG_FACTORY_H_ */ diff --git a/bundles/logging/log_service_v2/src/log_reader_service_impl.c b/bundles/logging/log_service_v2/src/log_reader_service_impl.c deleted file mode 100644 index 232d14171..000000000 --- a/bundles/logging/log_service_v2/src/log_reader_service_impl.c +++ /dev/null @@ -1,81 +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_impl.c - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include -#include - -#include "log_reader_service_impl.h" - -struct log_reader_data { - log_t *log; -}; - -celix_status_t logReaderService_create(log_t *log, log_reader_data_t **reader) { - celix_status_t status = CELIX_SUCCESS; - - *reader = (log_reader_data_t *) calloc(1, sizeof(**reader)); - - if (*reader == NULL) { - status = CELIX_ENOMEM; - } else { - (*reader)->log = log; - } - - return status; -} - -celix_status_t logReaderService_destroy(log_reader_data_t **reader) { - celix_status_t status = CELIX_SUCCESS; - - free(*reader); - reader = NULL; - - return status; -} - - - -celix_status_t logReaderService_getLog(log_reader_data_t *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_t *reader, log_listener_t *listener) { - return log_addLogListener(reader->log, listener); -} - -celix_status_t logReaderService_removeLogListener(log_reader_data_t *reader, log_listener_t *listener) { - return log_removeLogListener(reader->log, listener); -} - -celix_status_t logReaderService_removeAllLogListener(log_reader_data_t *reader) { - return log_removeAllLogListener(reader->log); -} - - diff --git a/bundles/logging/log_service_v2/src/log_reader_service_impl.h b/bundles/logging/log_service_v2/src/log_reader_service_impl.h deleted file mode 100644 index 9391dd49b..000000000 --- a/bundles/logging/log_service_v2/src/log_reader_service_impl.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_reader_service_impl.h - * - * \date Jun 26, 2011 - * \author Apache Celix Project Team - * \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_t *log, log_reader_data_t **reader); -celix_status_t logReaderService_destroy(log_reader_data_t **reader); - -celix_status_t logReaderService_getLog(log_reader_data_t *reader, linked_list_pt *list); - -celix_status_t logReaderService_addLogListener(log_reader_data_t *reader, log_listener_t *listener); -celix_status_t logReaderService_removeLogListener(log_reader_data_t *reader, log_listener_t *listener); -celix_status_t logReaderService_removeAllLogListener(log_reader_data_t *reader); - - -#endif /* LOG_READER_SERVICE_IMPL_H_ */ diff --git a/bundles/logging/log_service_v2/src/log_service_activator.c b/bundles/logging/log_service_v2/src/log_service_activator.c deleted file mode 100644 index a1d1ccf23..000000000 --- a/bundles/logging/log_service_v2/src/log_service_activator.c +++ /dev/null @@ -1,195 +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_activator.c - * - * \date Jun 25, 2011 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include -#include -#include "celix_constants.h" - -#include "celix_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 { - celix_bundle_context_t *bundleContext; - service_registration_t *logServiceFactoryReg; - service_registration_t *logReaderServiceReg; - - bundle_listener_t *bundleListener; - framework_listener_t *frameworkListener; - - log_t *logger; - service_factory_pt factory; - log_reader_data_t *reader; - log_reader_service_t *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 celix_bundleActivator_create(celix_bundle_context_t *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 celix_bundleActivator_start(void * userData, celix_bundle_context_t *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); - - celix_properties_t *props = celix_properties_create(); - - - 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 = celix_properties_create(); - - bundleContext_registerService(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, activator->reader_service, props, &activator->logReaderServiceReg); - return status; -} - -celix_status_t celix_bundleActivator_stop(void * userData, celix_bundle_context_t *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 celix_bundleActivator_destroy(void * userData, celix_bundle_context_t *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; -} diff --git a/bundles/logging/log_service_v2/src/log_service_impl.c b/bundles/logging/log_service_v2/src/log_service_impl.c deleted file mode 100644 index efcfc636f..000000000 --- a/bundles/logging/log_service_v2/src/log_service_impl.c +++ /dev/null @@ -1,97 +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_impl.c - * - * \date Jun 22, 2011 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#include - -#include "log_service_impl.h" -#include "module.h" -#include "bundle.h" - -struct log_service_data { - log_t *log; - celix_bundle_t *bundle; -}; - -celix_status_t logService_create(log_t *log, celix_bundle_t *bundle, log_service_data_t **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_t **logger) { - celix_status_t status = CELIX_SUCCESS; - - free(*logger); - logger = NULL; - - return status; -} - -celix_status_t logService_log(log_service_data_t *logger, log_level_t level, char * message) { - return logService_logSr(logger, NULL, level, message); -} - -celix_status_t logService_logSr(log_service_data_t *logger, service_reference_pt reference, log_level_t level, char * message) { - celix_status_t status; - log_entry_t *entry = NULL; - celix_bundle_t *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; -} diff --git a/bundles/logging/log_service_v2/src/log_service_impl.h b/bundles/logging/log_service_v2/src/log_service_impl.h deleted file mode 100644 index 7038435e7..000000000 --- a/bundles/logging/log_service_v2/src/log_service_impl.h +++ /dev/null @@ -1,39 +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_impl.h - * - * \date Jun 22, 2011 - * \author Apache Celix Project Team - * \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_t *log, celix_bundle_t *bundle, log_service_data_t **logger); -celix_status_t logService_destroy(log_service_data_t **logger); -celix_status_t logService_log(log_service_data_t *logger, log_level_t level, char * message); -celix_status_t logService_logSr(log_service_data_t *logger, service_reference_pt reference, log_level_t level, char * message); - - -#endif /* LOG_SERVICE_IMPL_H_ */ diff --git a/bundles/logging/log_writers/syslog_writer/gtest/CMakeLists.txt b/bundles/logging/log_writers/syslog_writer/gtest/CMakeLists.txt index 87b4228e7..94dcc8d52 100644 --- a/bundles/logging/log_writers/syslog_writer/gtest/CMakeLists.txt +++ b/bundles/logging/log_writers/syslog_writer/gtest/CMakeLists.txt @@ -19,7 +19,7 @@ add_executable(test_syslog_writer src/SyslogWriterTestSuite.cc ) -target_link_libraries(test_syslog_writer PRIVATE Celix::log_service_api GTest::gtest GTest::gtest_main) +target_link_libraries(test_syslog_writer PRIVATE Celix::framework Celix::log_service_api GTest::gtest GTest::gtest_main) add_celix_bundle_dependencies(test_syslog_writer Celix::log_admin Celix::syslog_writer) target_compile_definitions(test_syslog_writer PRIVATE -DLOG_ADMIN_BUNDLE=\"$\") target_compile_definitions(test_syslog_writer PRIVATE -DSYSLOG_WRITER_BUNDLE=\"$\") diff --git a/bundles/shell/shell/src/c_shell_activator.c b/bundles/shell/shell/src/c_shell_activator.c index eaae2aaf8..6dcc0d5d9 100644 --- a/bundles/shell/shell/src/c_shell_activator.c +++ b/bundles/shell/shell/src/c_shell_activator.c @@ -36,7 +36,6 @@ struct shell_bundle_activator { long shellSvcId; long trackerId; - long legacyTrackerId; }; typedef struct shell_bundle_activator shell_bundle_activator_t; @@ -109,21 +108,8 @@ celix_status_t celix_bundleActivator_start(void *activatorData, celix_bundle_con opts.filter.ignoreServiceLanguage = true; opts.filter.serviceName = CELIX_SHELL_COMMAND_SERVICE_NAME; activator->trackerId = celix_bundleContext_trackServicesWithOptions(ctx, &opts); - activator->legacyTrackerId = -1L; } -#ifdef CELIX_INSTALL_DEPRECATED_API - if (status == CELIX_SUCCESS) { - celix_service_tracking_options_t opts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS; - opts.callbackHandle = activator->shell; - opts.addWithProperties = (void*) shell_addLegacyCommand; - opts.removeWithProperties = (void*) shell_removeLegacyCommand; - opts.filter.ignoreServiceLanguage = true; - opts.filter.serviceName = OSGI_SHELL_COMMAND_SERVICE_NAME; - activator->legacyTrackerId = celix_bundleContext_trackServicesWithOptions(ctx, &opts); - } -#endif - return status; } @@ -136,8 +122,6 @@ celix_status_t celix_bundleActivator_stop(void *activatorData, celix_bundle_cont celix_stdCommands_destroy(activator->stdCommands); celix_bundleContext_unregisterService(ctx, activator->shellSvcId); celix_bundleContext_stopTracker(ctx, activator->trackerId); - celix_bundleContext_stopTracker(ctx, activator->legacyTrackerId); - } else { status = CELIX_ILLEGAL_ARGUMENT; }