diff options
4 files changed, 16 insertions, 77 deletions
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 010816808c..609b240301 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -700,6 +700,14 @@ class MessageHelper { ApplicationSharedPtr app, int32_t function_id); + /** + * @brief Prints SmartObject contents to log file + * @param object - SmartObject to print + * @return always True as this function is used for internal debug purposes + * only + * @note Function prints SmartObject only in DEBUG build mode. There will not + * be any print in RELEASE build mode + */ static bool PrintSmartObject(const smart_objects::SmartObject& object); template <typename From, typename To> diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 02c41e0472..b61a405aa4 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1305,9 +1305,7 @@ bool ApplicationManagerImpl::StartNaviService( return false; } else if (!converted_params.empty()) { LOG4CXX_INFO(logger_, "Sending video configuration params"); -#ifdef DEBUG MessageHelper::PrintSmartObject(converted_params); -#endif bool request_sent = application(app_id)->SetVideoConfig(service_type, converted_params); if (request_sent) { diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 5bda17ecbd..a52cb52fbe 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -65,6 +65,8 @@ #include "formatters/formatter_json_rpc.h" #include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "json/json.h" +#include "formatters/CFormatterJsonBase.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -2219,11 +2221,7 @@ void MessageHelper::SendSystemRequestNotification( commands::CommandImpl::protocol_version_; content[strings::params][strings::connection_key] = connection_key; - -#ifdef DEBUG PrintSmartObject(content); -#endif - DCHECK(app_mngr.GetRPCService().ManageMobileCommand( std::make_shared<smart_objects::SmartObject>(content), commands::Command::SOURCE_SDL)); @@ -2873,76 +2871,12 @@ void MessageHelper::SubscribeApplicationToSoftButton( app->SubscribeToSoftButtons(function_id, softbuttons_id); } -// TODO(AK): change printf to logger bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { - return true; -#ifdef ENABLE_LOG - static uint32_t tab = 0; - std::string tab_buffer; - - if (tab == 0) { - printf("\n-------------------------------------------------------------"); - } - - for (uint32_t i = 0; i < tab; ++i) { - tab_buffer += "\t"; - } - - switch (object.getType()) { - case ns_smart_device_link::ns_smart_objects::SmartType_Array: { - for (size_t i = 0; i < object.length(); i++) { - ++tab; - - printf("\n%s%zu: ", tab_buffer.c_str(), i); - if (!PrintSmartObject(object.getElement(i))) { - printf("\n"); - return false; - } - } - break; - } - case ns_smart_device_link::ns_smart_objects::SmartType_Map: { - std::set<std::string> keys = object.enumerate(); - - for (std::set<std::string>::const_iterator key = keys.begin(); - key != keys.end(); - key++) { - ++tab; - - printf("\n%s%s: ", tab_buffer.c_str(), (*key).c_str()); - if (!PrintSmartObject(object[(*key).c_str()])) { - printf("\n"); - return false; - } - } - break; - } - case ns_smart_device_link::ns_smart_objects::SmartType_Boolean: - object.asBool() ? printf("true\n") : printf("false\n"); - break; - case ns_smart_device_link::ns_smart_objects::SmartType_Double: { - printf("%f", object.asDouble()); - break; - } - case ns_smart_device_link::ns_smart_objects::SmartType_Integer: - printf("%lld", static_cast<long long int>(object.asInt())); - break; - case ns_smart_device_link::ns_smart_objects::SmartType_String: - printf("%s", object.asString().c_str()); - break; - case ns_smart_device_link::ns_smart_objects::SmartType_Character: - printf("%c", object.asChar()); - break; - default: - printf("PrintSmartObject - default case\n"); - break; - } - - if (0 != tab) { - --tab; - } else { - printf("\n-------------------------------------------------------------\n"); - } +#ifdef DEBUG + Json::Value tmp; + namespace Formatters = ns_smart_device_link::ns_json_handler::formatters; + Formatters::CFormatterJsonBase::objToJsonValue(object, tmp); + LOG4CXX_DEBUG(logger_, "SMART OBJECT: " << tmp.toStyledString()); #endif return true; } diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index 217af091b5..7a68ae5779 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -71,9 +71,8 @@ bool RPCServiceImpl::ManageMobileCommand( LOG4CXX_WARN(logger_, "Low Voltage is active"); return false; } -#ifdef DEBUG + MessageHelper::PrintSmartObject(*message); -#endif const uint32_t connection_key = static_cast<uint32_t>( (*message)[strings::params][strings::connection_key].asUInt()); |