From e4779ed3ba93403e1298f7cb46b9bce9ca49c31b Mon Sep 17 00:00:00 2001 From: Daniel Falk <falk@haleytek.com> Date: Thu, 20 Jun 2024 14:48:03 +0200 Subject: [PATCH 1/5] Add support for forwarding trace messages to logs Initially, support for tracing to DLT was added. Later, support for forwarding trace messages to logs on Android was added. This commit adds support for forwarding trace messages to logs on all platforms by introducing the build flag TRACE_TO_LOGS. If either USE_DLT or TRACE_TO_LOGS is defined when building vsomeip, support for generating trace messages will be included in the library. The Android.bp file has been updated to include TRACE_TO_LOGS instead of USE_DLT, which allows removal of a number of additional ifdef guards around DLT-specific code. Co-authored-by: Daniel Freiermuth <danielfr@haleytek.com> --- Android.bp | 2 +- documentation/vsomeipUserGuide | 8 +++-- examples/routingmanagerd/routingmanagerd.cpp | 4 --- implementation/logger/include/logger_impl.hpp | 4 --- implementation/logger/src/logger_impl.cpp | 6 ---- implementation/logger/src/message.cpp | 2 -- .../routing/include/routing_manager_base.hpp | 4 +-- .../routing/src/routing_manager_base.cpp | 10 +++---- .../routing/src/routing_manager_client.cpp | 12 ++++---- .../routing/src/routing_manager_impl.cpp | 30 +++++++++---------- .../runtime/src/application_impl.cpp | 2 +- .../tracing/include/connector_impl.hpp | 4 --- implementation/tracing/src/connector_impl.cpp | 26 +++++++--------- .../include/common/vsomeip_app_utilities.hpp | 2 -- test/common/src/vsomeip_app_utilities.cpp | 4 --- test/network_tests/someip_test_globals.hpp | 2 -- 16 files changed, 47 insertions(+), 75 deletions(-) diff --git a/Android.bp b/Android.bp index f314f22b1..6b47b2bd8 100644 --- a/Android.bp +++ b/Android.bp @@ -83,7 +83,7 @@ cc_library_shared { "-DVSOMEIP_VERSION=\"3.4.10\"", "-DVSOMEIP_COMPAT_VERSION=\"3.4.10\"", "-DVSOMEIP_BASE_PATH=\"/vendor/run/someip/\"", - "-DUSE_DLT", + "-DTRACE_TO_LOGS", ], ldflags: [ diff --git a/documentation/vsomeipUserGuide b/documentation/vsomeipUserGuide index 4c1f9842e..17309a6b6 100644 --- a/documentation/vsomeipUserGuide +++ b/documentation/vsomeipUserGuide @@ -438,8 +438,12 @@ status. Setting a value greater than zero enables the logging. + Specifies whether the tracing of the SOME/IP messages is enabled (valid values: _true, false_). Default value is _false_. -If tracing is enabled, the messages will be forwarded to DLT by -the <<traceconnector, Trace Connector>> +If tracing is enabled, the trace messages will be forwarded to DLT and/or +logs by the <<traceconnector, Trace Connector>>, depending on the following +build flags: +* USE_DLT +* TRACE_TO_LOGS + + ** 'sd_enable' + diff --git a/examples/routingmanagerd/routingmanagerd.cpp b/examples/routingmanagerd/routingmanagerd.cpp index 65d9d016a..8299c1918 100644 --- a/examples/routingmanagerd/routingmanagerd.cpp +++ b/examples/routingmanagerd/routingmanagerd.cpp @@ -16,10 +16,8 @@ #include <vsomeip/internal/logger.hpp> #ifdef USE_DLT -#ifndef ANDROID #include <dlt/dlt.h> #endif -#endif static std::shared_ptr<vsomeip::application> its_application; @@ -65,10 +63,8 @@ void routingmanagerd_stop(int _signal) { */ int routingmanagerd_process(bool _is_quiet) { #ifdef USE_DLT -#ifndef ANDROID if (!_is_quiet) DLT_REGISTER_APP(VSOMEIP_LOG_DEFAULT_APPLICATION_ID, VSOMEIP_LOG_DEFAULT_APPLICATION_NAME); -#endif #else (void)_is_quiet; #endif diff --git a/implementation/logger/include/logger_impl.hpp b/implementation/logger/include/logger_impl.hpp index 34f006468..7850221c2 100644 --- a/implementation/logger/include/logger_impl.hpp +++ b/implementation/logger/include/logger_impl.hpp @@ -10,10 +10,8 @@ #include <mutex> #ifdef USE_DLT -#ifndef ANDROID #include <dlt/dlt.h> #endif -#endif #include <vsomeip/internal/logger.hpp> @@ -48,10 +46,8 @@ class logger_impl { mutable std::mutex configuration_mutex_; #ifdef USE_DLT -#ifndef ANDROID DLT_DECLARE_CONTEXT(dlt_) #endif -#endif }; } // namespace logger diff --git a/implementation/logger/src/logger_impl.cpp b/implementation/logger/src/logger_impl.cpp index b7cd57e31..b4bd9b582 100644 --- a/implementation/logger/src/logger_impl.cpp +++ b/implementation/logger/src/logger_impl.cpp @@ -25,22 +25,18 @@ logger_impl::init(const std::shared_ptr<configuration> &_configuration) { # define VSOMEIP_LOG_DEFAULT_CONTEXT_ID "VSIP" # define VSOMEIP_LOG_DEFAULT_CONTEXT_NAME "vSomeIP context" -#ifndef ANDROID std::string its_context_id = runtime::get_property("LogContext"); if (its_context_id == "") its_context_id = VSOMEIP_LOG_DEFAULT_CONTEXT_ID; DLT_REGISTER_CONTEXT(its_logger->dlt_, its_context_id.c_str(), VSOMEIP_LOG_DEFAULT_CONTEXT_NAME); #endif -#endif } logger_impl::~logger_impl() { #ifdef USE_DLT -#ifndef ANDROID DLT_UNREGISTER_CONTEXT(dlt_); #endif -#endif } std::shared_ptr<configuration> @@ -59,7 +55,6 @@ logger_impl::set_configuration( } #ifdef USE_DLT -#ifndef ANDROID void logger_impl::log(level_e _level, const char *_data) { @@ -91,7 +86,6 @@ logger_impl::log(level_e _level, const char *_data) { DLT_LOG_STRING(dlt_, its_level, _data); } #endif -#endif static std::shared_ptr<logger_impl> *the_logger_ptr__(nullptr); static std::mutex the_logger_mutex__; diff --git a/implementation/logger/src/message.cpp b/implementation/logger/src/message.cpp index 015e8e35b..7f509743f 100644 --- a/implementation/logger/src/message.cpp +++ b/implementation/logger/src/message.cpp @@ -192,9 +192,7 @@ message::~message() try { } if (its_configuration->has_dlt_log()) { #ifdef USE_DLT -#ifndef ANDROID its_logger->log(level_, buffer_.data_.str().c_str()); -#endif #endif // USE_DLT } } catch (const std::exception& e) { diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp index a7ba02438..c6ec0aa43 100644 --- a/implementation/routing/include/routing_manager_base.hpp +++ b/implementation/routing/include/routing_manager_base.hpp @@ -30,7 +30,7 @@ namespace vsomeip_v3 { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) namespace trace { class connector_impl; } // namespace trace @@ -308,7 +308,7 @@ class routing_manager_base : public routing_manager, std::mutex event_registration_mutex_; -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) std::shared_ptr<trace::connector_impl> tc_; #endif diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index 047e6566e..5eda7143f 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -13,7 +13,7 @@ #include "../../protocol/include/send_command.hpp" #include "../../security/include/policy_manager_impl.hpp" #include "../../security/include/security.hpp" -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) #include "../../tracing/include/connector_impl.hpp" #endif #include "../../utility/include/byteorder.hpp" @@ -26,7 +26,7 @@ routing_manager_base::routing_manager_base(routing_manager_host *_host) : io_(host_->get_io()), configuration_(host_->get_configuration()), debounce_timer(host_->get_io()) -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) , tc_(trace::connector_impl::get()) #endif { @@ -1320,7 +1320,7 @@ void routing_manager_base::remove_eventgroup_info(service_t _service, bool routing_manager_base::send_local_notification(client_t _client, const byte_t *_data, uint32_t _size, instance_t _instance, bool _reliable, uint8_t _status_check, bool _force) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) bool has_local(false); #endif bool has_remote(false); @@ -1338,7 +1338,7 @@ bool routing_manager_base::send_local_notification(client_t _client, has_remote = true; continue; } -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) else { has_local = true; } @@ -1351,7 +1351,7 @@ bool routing_manager_base::send_local_notification(client_t _client, } } } -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) // Trace the message if a local client but will _not_ be forwarded to the routing manager if (has_local && !has_remote) { trace::header its_header; diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index dbb2bd2eb..dc4fc514e 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -64,7 +64,7 @@ #include "../../security/include/security.hpp" #include "../../utility/include/byteorder.hpp" #include "../../utility/include/utility.hpp" -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) #include "../../tracing/include/connector_impl.hpp" #endif @@ -893,7 +893,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, // notify_one its_target = ep_mgr_->find_local(_client); if (its_target) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) trace::header its_header; if (its_header.prepare(nullptr, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, @@ -905,14 +905,14 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, } // If no direct endpoint could be found // or for notifications ~> route to routing_manager_stub -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) bool message_to_stub(false); #endif if (!its_target) { std::lock_guard<std::mutex> its_lock(sender_mutex_); if (sender_) { its_target = sender_; -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) message_to_stub = true; #endif } else { @@ -933,7 +933,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, send = has_remote_subscribers; } } -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) else if (!message_to_stub) { trace::header its_header; if (its_header.prepare(nullptr, true, _instance)) @@ -1207,7 +1207,7 @@ void routing_manager_client::on_message( cache_event_payload(its_message); } } - #ifdef USE_DLT + #if defined(USE_DLT) || defined(TRACE_TO_LOGS) if (client_side_logging_ && (client_side_logging_filter_.empty() || (1 == client_side_logging_filter_.count(std::make_tuple(its_message->get_service(), ANY_INSTANCE))) diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 79f408045..4c349b1ae 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -50,7 +50,7 @@ #include "../../service_discovery/include/service_discovery.hpp" #include "../../utility/include/byteorder.hpp" #include "../../utility/include/utility.hpp" -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) #include "../../tracing/include/connector_impl.hpp" #endif @@ -61,7 +61,7 @@ #include "../../e2e_protection/include/e2e/profile/e2e_provider.hpp" #endif -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) #include "../../tracing/include/connector_impl.hpp" #endif @@ -894,7 +894,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, its_target = find_local(its_client); } else if (is_notification && _client && !is_service_discovery) { // Selective notifications! if (_client == get_client()) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) trace::header its_header; if (its_header.prepare(its_target, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, @@ -909,7 +909,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, } if (its_target) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) if ((is_request && its_client == get_client()) || (is_response && find_local_client(its_service, _instance) == get_client()) || (is_notification && find_local_client(its_service, _instance) == VSOMEIP_ROUTING_CLIENT)) { @@ -962,7 +962,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, its_target = ep_mgr_impl_->find_or_create_remote_client( its_service, _instance, _reliable); if (its_target) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) trace::header its_header; if (its_header.prepare(its_target, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, @@ -991,7 +991,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, _data[VSOMEIP_METHOD_POS_MAX]); std::shared_ptr<event> its_event = find_event(its_service, _instance, its_method); if (its_event) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) bool has_sent(false); #endif std::set<std::shared_ptr<endpoint_definition>> its_targets; @@ -1042,11 +1042,11 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, } else { its_udp_server_endpoint->send_to(target, _data, _size); } -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) has_sent = true; #endif } -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) if (has_sent) { trace::header its_header; if (its_header.prepare(nullptr, true, _instance)) @@ -1077,7 +1077,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, its_target = is_service_discovery ? (sd_info_ ? sd_info_->get_endpoint(false) : nullptr) : its_info->get_endpoint(_reliable); if (its_target) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) trace::header its_header; if (its_header.prepare(its_target, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, @@ -1172,7 +1172,7 @@ bool routing_manager_impl::send_to( _target->get_remote_port(), _target->is_reliable()); if (its_endpoint) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) trace::header its_header; if (its_header.prepare(its_endpoint, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, @@ -1193,7 +1193,7 @@ bool routing_manager_impl::send_via_sd( _target->is_reliable()); if (its_endpoint) { -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) if (tc_->is_sd_enabled()) { trace::header its_header; if (its_header.prepare(its_endpoint, true, 0x0)) @@ -1491,7 +1491,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, uint8_t its_check_status = e2e::profile_interface::generic_check_status::E2E_OK; instance_t its_instance(0x0); message_type_e its_message_type; -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) bool is_forwarded(true); #endif if (_size >= VSOMEIP_SOMEIP_HEADER_SIZE) { @@ -1620,14 +1620,14 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, } // Common way of message handling -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) is_forwarded = #endif on_message(its_service, its_instance, _data, _size, _receiver->is_reliable(), _bound_client, _sec_client, its_check_status, true); } } -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) if (is_forwarded) { trace::header its_header; const boost::asio::ip::address_v4 its_remote_address = @@ -3279,7 +3279,7 @@ void routing_manager_impl::send_error(return_code_e _return_code, its_endpoint_def->get_remote_port(), its_endpoint_def->is_reliable()); if (its_endpoint) { - #ifdef USE_DLT + #if defined(USE_DLT) || defined(TRACE_TO_LOGS) trace::header its_header; if (its_header.prepare(its_endpoint, true, _instance)) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index db880b42d..211e49e60 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -309,7 +309,7 @@ bool application_impl::init() { routing_->init(); -#ifdef USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) // Tracing std::shared_ptr<trace::connector_impl> its_connector = trace::connector_impl::get(); diff --git a/implementation/tracing/include/connector_impl.hpp b/implementation/tracing/include/connector_impl.hpp index e5c90d2ad..0a147587a 100644 --- a/implementation/tracing/include/connector_impl.hpp +++ b/implementation/tracing/include/connector_impl.hpp @@ -7,10 +7,8 @@ #define VSOMEIP_V3_TRACE_CONNECTOR_HPP_ #ifdef USE_DLT -#ifndef ANDROID #include <dlt/dlt.h> #endif -#endif #include <mutex> #include <vector> @@ -72,11 +70,9 @@ class connector_impl : public connector { std::shared_ptr<channel_impl> get_channel_impl(const std::string &_id) const; #ifdef USE_DLT -#ifndef ANDROID std::map<std::string, std::shared_ptr<DltContext>> contexts_; mutable std::mutex contexts_mutex_; #endif -#endif }; diff --git a/implementation/tracing/src/connector_impl.cpp b/implementation/tracing/src/connector_impl.cpp index 2f93bd098..bc22af1b0 100644 --- a/implementation/tracing/src/connector_impl.cpp +++ b/implementation/tracing/src/connector_impl.cpp @@ -50,7 +50,6 @@ connector_impl::connector_impl() : = std::make_shared<channel_impl>(VSOMEIP_TC_DEFAULT_CHANNEL_ID, VSOMEIP_TC_DEFAULT_CHANNEL_NAME); #ifdef USE_DLT -#ifndef ANDROID std::shared_ptr<DltContext> its_default_context = std::make_shared<DltContext>(); @@ -59,7 +58,6 @@ connector_impl::connector_impl() : VSOMEIP_TC_DEFAULT_CHANNEL_ID, VSOMEIP_TC_DEFAULT_CHANNEL_NAME, DLT_LOG_INFO, DLT_TRACE_STATUS_ON); #endif -#endif } connector_impl::~connector_impl() { @@ -104,10 +102,8 @@ void connector_impl::configure(const std::shared_ptr<cfg::trace> &_configuration void connector_impl::reset() { #ifdef USE_DLT -#ifndef ANDROID std::lock_guard<std::mutex> its_contexts_lock(contexts_mutex_); contexts_.clear(); -#endif #endif // reset to default std::lock_guard<std::mutex> its_lock_channels(channels_mutex_); @@ -155,13 +151,11 @@ std::shared_ptr<channel> connector_impl::add_channel( // register context #ifdef USE_DLT -#ifndef ANDROID std::lock_guard<std::mutex> its_contexts_lock(contexts_mutex_); std::shared_ptr<DltContext> its_context = std::make_shared<DltContext>(); contexts_[_id] = its_context; DLT_REGISTER_CONTEXT_LL_TS(*(its_context.get()), _id.c_str(), _name.c_str(), DLT_LOG_INFO, DLT_TRACE_STATUS_ON); -#endif #endif return its_channel; @@ -178,13 +172,11 @@ bool connector_impl::remove_channel(const trace_channel_t &_id) { if (has_removed) { // unregister context #ifdef USE_DLT -#ifndef ANDROID std::lock_guard<std::mutex> its_contexts_lock(contexts_mutex_); auto its_context = contexts_.find(_id); if (its_context != contexts_.end()) { DLT_UNREGISTER_CONTEXT(*(its_context->second.get())); } -#endif #endif } @@ -206,7 +198,7 @@ std::shared_ptr<channel_impl> connector_impl::get_channel_impl(const std::string void connector_impl::trace(const byte_t *_header, uint16_t _header_size, const byte_t *_data, uint32_t _data_size) { -#if USE_DLT +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) if (!is_enabled_) return; @@ -236,13 +228,13 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, // Forward to channel if the filter set of the channel allows std::lock_guard<std::mutex> its_channels_lock(channels_mutex_); - #ifndef ANDROID + #ifdef USE_DLT std::lock_guard<std::mutex> its_contexts_lock(contexts_mutex_); #endif for (auto its_channel : channels_) { auto ftype = its_channel.second->matches(its_service, its_instance, its_method); if (ftype.first) { - #ifndef ANDROID + #ifdef USE_DLT auto its_context = contexts_.find(its_channel.second->get_id()); if (its_context != contexts_.end()) { try { @@ -269,7 +261,8 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, // This should never happen! VSOMEIP_ERROR << "tracing: found channel without DLT context!"; } - #else + #endif + #ifdef TRACE_TO_LOGS std::stringstream ss; ss << "TC:"; for(int i = 0; i < _header_size; i++) { @@ -280,9 +273,12 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, for(int i = 0; i < its_data_size; i++) { ss << ' ' << std::setfill('0') << std::setw(2) << std::hex << int(_data[i]); } - std::string app = runtime::get_property("LogApplication"); - - ALOGI(app.c_str(), ss.str().c_str()); + #ifdef ANDROID + std::string app = runtime::get_property("LogApplication"); + ALOGI(app.c_str(), ss.str().c_str()); + #else + VSOMEIP_INFO << ss; + #endif #endif } } diff --git a/test/common/include/common/vsomeip_app_utilities.hpp b/test/common/include/common/vsomeip_app_utilities.hpp index 5ad0be398..0fd5ad379 100644 --- a/test/common/include/common/vsomeip_app_utilities.hpp +++ b/test/common/include/common/vsomeip_app_utilities.hpp @@ -13,10 +13,8 @@ #include <vsomeip/internal/logger.hpp> #ifdef USE_DLT -#ifndef ANDROID #include <dlt/dlt.h> #endif -#endif namespace vsomeip_utilities { diff --git a/test/common/src/vsomeip_app_utilities.cpp b/test/common/src/vsomeip_app_utilities.cpp index f2e00106c..14895494e 100644 --- a/test/common/src/vsomeip_app_utilities.cpp +++ b/test/common/src/vsomeip_app_utilities.cpp @@ -29,19 +29,15 @@ base_logger::base_logger(const char *dlt_application_id, const char *dlt_applica _dlt_application_name(dlt_application_name) { #ifdef USE_DLT -#ifndef ANDROID DLT_REGISTER_APP(_dlt_application_id, _dlt_application_name); #endif -#endif } base_logger::~base_logger() { #ifdef USE_DLT -#ifndef ANDROID DLT_UNREGISTER_APP(); #endif -#endif } base_vsip_app::base_vsip_app(const char *app_name_, const char *app_id_) : base_logger( app_name_, app_id_) diff --git a/test/network_tests/someip_test_globals.hpp b/test/network_tests/someip_test_globals.hpp index 4f1a363b5..8cbe794aa 100644 --- a/test/network_tests/someip_test_globals.hpp +++ b/test/network_tests/someip_test_globals.hpp @@ -10,10 +10,8 @@ #include <vsomeip/internal/logger.hpp> #ifdef USE_DLT -#ifndef ANDROID #include <dlt/dlt.h> #endif -#endif namespace vsomeip_test { From c4a4b4c7cdbb5341f5e5bf4dcdfeb0b3294b4276 Mon Sep 17 00:00:00 2001 From: Daniel Falk <falk@haleytek.com> Date: Wed, 26 Jun 2024 13:23:57 +0200 Subject: [PATCH 2/5] Amend missing call to str() --- implementation/tracing/src/connector_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementation/tracing/src/connector_impl.cpp b/implementation/tracing/src/connector_impl.cpp index bc22af1b0..d8496a0aa 100644 --- a/implementation/tracing/src/connector_impl.cpp +++ b/implementation/tracing/src/connector_impl.cpp @@ -277,7 +277,7 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, std::string app = runtime::get_property("LogApplication"); ALOGI(app.c_str(), ss.str().c_str()); #else - VSOMEIP_INFO << ss; + VSOMEIP_INFO << ss.str(); #endif #endif } From f37185a2b799e029b0de428aeaad34c2e86a2941 Mon Sep 17 00:00:00 2001 From: Daniel Falk <daniel.falk@haleytek.com> Date: Tue, 10 Sep 2024 12:40:28 +0200 Subject: [PATCH 3/5] Remove special trace log handling for Android VSOMEIP_INFO already provides the same functionality out of the box. --- implementation/tracing/src/connector_impl.cpp | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/implementation/tracing/src/connector_impl.cpp b/implementation/tracing/src/connector_impl.cpp index d8496a0aa..359c928c6 100644 --- a/implementation/tracing/src/connector_impl.cpp +++ b/implementation/tracing/src/connector_impl.cpp @@ -18,20 +18,6 @@ #include "../../configuration/include/trace.hpp" #include "../../utility/include/byteorder.hpp" -#ifdef ANDROID -#include <utils/Log.h> - -#ifdef ALOGI -#undef ALOGI -#endif - -#define ALOGI(LOG_TAG, ...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -#ifndef LOGE -#define LOGI ALOGI -#endif - -#endif - namespace vsomeip_v3 { namespace trace { @@ -273,12 +259,7 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, for(int i = 0; i < its_data_size; i++) { ss << ' ' << std::setfill('0') << std::setw(2) << std::hex << int(_data[i]); } - #ifdef ANDROID - std::string app = runtime::get_property("LogApplication"); - ALOGI(app.c_str(), ss.str().c_str()); - #else - VSOMEIP_INFO << ss.str(); - #endif + VSOMEIP_INFO << ss.str(); #endif } } From 61a1fb2e814f5fb8d85deee72192fe39285bcdbe Mon Sep 17 00:00:00 2001 From: falk-haleytek <daniel.falk@haleytek.com> Date: Tue, 10 Sep 2024 20:53:19 +0200 Subject: [PATCH 4/5] Only trace to logs if not using DLT to avoid duplicated messages Co-authored-by: Duarte Fonseca <42354362+duartenfonseca@users.noreply.github.com> --- implementation/tracing/src/connector_impl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/implementation/tracing/src/connector_impl.cpp b/implementation/tracing/src/connector_impl.cpp index 50afa383d..ef8b3d272 100644 --- a/implementation/tracing/src/connector_impl.cpp +++ b/implementation/tracing/src/connector_impl.cpp @@ -247,8 +247,7 @@ void connector_impl::trace(const byte_t *_header, uint16_t _header_size, // This should never happen! VSOMEIP_ERROR << "tracing: found channel without DLT context!"; } - #endif - #ifdef TRACE_TO_LOGS + #else std::stringstream ss; ss << "TC:"; for(int i = 0; i < _header_size; i++) { From 1ee7b58fd2451cfd42d69290abde7c5a5e92745c Mon Sep 17 00:00:00 2001 From: Daniel Falk <daniel.falk@haleytek.com> Date: Tue, 8 Oct 2024 11:22:56 +0200 Subject: [PATCH 5/5] Fix ifdef mistake after rebasing on master --- implementation/routing/include/routing_manager_base.hpp | 2 +- implementation/routing/src/routing_manager_base.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp index 6c67e95fe..b2fdd74d5 100644 --- a/implementation/routing/include/routing_manager_base.hpp +++ b/implementation/routing/include/routing_manager_base.hpp @@ -352,7 +352,7 @@ class routing_manager_base : public routing_manager, std::mutex routing_state_mutex_; routing_state_e routing_state_; -#ifdef USE_DLT || defined(TRACE_TO_LOGS) +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) std::shared_ptr<trace::connector_impl> tc_; #endif diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index d0b019eba..1c921738f 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -27,7 +27,7 @@ routing_manager_base::routing_manager_base(routing_manager_host *_host) : configuration_(host_->get_configuration()), debounce_timer(host_->get_io()), routing_state_(routing_state_e::RS_UNKNOWN) -#ifdef USE_DLT || defined(TRACE_TO_LOGS) +#if defined(USE_DLT) || defined(TRACE_TO_LOGS) , tc_(trace::connector_impl::get()) #endif {