From: Piotr Kosko Date: Mon, 27 Nov 2017 07:07:18 +0000 (+0100) Subject: [Common] Preventing logger from runtime format definition X-Git-Tag: submit/tizen_4.0/20171201.130234~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1a36288ebfa8206c51df34326babf1d4eb969b4;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Common] Preventing logger from runtime format definition [Bug] 1. ScopeLogger macro was using string format defined in runtime, instead of compilation time. 2. Some logs had invalid format specifiers, needed a hack with replacing body of ScopeLogger and Logger* with printf to discover them. [Solution] ScopeLogger class constructor is now not responsible for logging object creation. This log was moved to macro, which makes possible compilation time format specification. [Verification] Currently, __dlog_print implementation seems not to validate formats as printf() does. I replaced the body of ScopeLogger macro with printf() call, to find invalid format cases(compilation warnings appeared). After fixing, I recovered __dlog_print based implementation. 1. Code compiles without errors. 2. ScopeLogger enter and exit logs appear correctly. 3. Undefining TIZEN_DEBUG_ENABLE makes that ScopeLogger objects are no longer created - checked with logs and chrome console. Change-Id: I736ad5ed7ce191c7099417ef2e0cd81de4eb00a2 Signed-off-by: Piotr Kosko --- diff --git a/src/alarm/alarm_manager.cc b/src/alarm/alarm_manager.cc index 8ca564bc..2588fa25 100644 --- a/src/alarm/alarm_manager.cc +++ b/src/alarm/alarm_manager.cc @@ -541,7 +541,7 @@ PlatformResult AlarmManager::GetAlarm(int id, picojson::object& obj) { if (!platform_result) { return LogAndCreateResult( platform_result.error_code(), platform_result.message().c_str(), - ("Failed to get AppControl: %d (%s)", platform_result.error_code(), + ("Failed to get AppControl: %d (%s)", static_cast(platform_result.error_code()), platform_result.message().c_str())); } } @@ -720,10 +720,10 @@ static bool AlarmIterateCB(int alarm_id, void* user_data) { alarm_ids->push_back(alarm_id); return true; } +#include void AlarmManager::GetAll(const picojson::value& args, picojson::object& out) { ScopeLogger(); - std::vector alarm_ids; int ret = alarm_foreach_registered_alarm(AlarmIterateCB, &alarm_ids); @@ -793,7 +793,6 @@ void AlarmManager::GetRemainingSeconds(const picojson::value& args, picojson::ob void AlarmManager::GetNextScheduledDate(const picojson::value& args, picojson::object& out) { ScopeLogger(); - int id = 0; if (args.contains("id") && args.get("id").is()) { diff --git a/src/archive/archive_callback_data.cc b/src/archive/archive_callback_data.cc index f761270b..89246164 100644 --- a/src/archive/archive_callback_data.cc +++ b/src/archive/archive_callback_data.cc @@ -58,7 +58,7 @@ OperationCallbackData::~OperationCallbackData() { } void OperationCallbackData::setError(const ErrorCode& err_code, const std::string& err_message) { - ScopeLogger("Setting error, code is: [%d]", err_code); + ScopeLogger("Setting error, code is: [%d]", static_cast(err_code)); // store only first error if (!m_is_error) { m_err_code = err_code; diff --git a/src/calendar/calendar.cc b/src/calendar/calendar.cc index ef161c0e..556274dc 100644 --- a/src/calendar/calendar.cc +++ b/src/calendar/calendar.cc @@ -598,7 +598,7 @@ PlatformResult Calendar::Find(const picojson::object& args, picojson::array& arr if ((status = ErrorChecker(error_code)).IsError()) return status; } else { return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Invalid union type!", - ("Invalid union type: %d", calType)); + ("Invalid union type: %d", static_cast(calType))); } } intermediate_filters.pop_back(); diff --git a/src/calendar/calendar_item.cc b/src/calendar/calendar_item.cc index 7e209b44..d42f743f 100644 --- a/src/calendar/calendar_item.cc +++ b/src/calendar/calendar_item.cc @@ -384,7 +384,7 @@ PlatformResult CalendarItem::SetInt(int type, calendar_record_h rec, const std:: PlatformResult CalendarItem::SetInt(int type, calendar_record_h rec, const std::string& property, int value) { - ScopeLogger("set: %s" + property); + ScopeLogger("set: %s", property.c_str()); unsigned int prop; PlatformResult status = GetPlatformProperty(type, property, &prop); @@ -397,7 +397,7 @@ PlatformResult CalendarItem::SetInt(int type, calendar_record_h rec, const std:: PlatformResult CalendarItem::GetInt(int type, calendar_record_h rec, const std::string& property, int* value) { - ScopeLogger("set: %s" + property); + ScopeLogger("set: %s", property.c_str()); unsigned int prop; PlatformResult status = GetPlatformProperty(type, property, &prop); @@ -541,7 +541,7 @@ PlatformResult CalendarItem::SetCaltime(calendar_record_h rec, unsigned int prop PlatformResult CalendarItem::GetCaltime(int type, calendar_record_h rec, const std::string& property, calendar_time_s* cal_time, bool throw_on_error) { - ScopeLogger("set: %s" + property); + ScopeLogger("set: %s", property.c_str()); unsigned int prop; PlatformResult status = GetPlatformProperty(type, property, &prop); @@ -588,7 +588,7 @@ PlatformResult CalendarItem::SetLli(calendar_record_h rec, unsigned int property PlatformResult CalendarItem::GetLli(int type, calendar_record_h rec, const std::string& property, long long int* lli) { - ScopeLogger("set: %s" + property); + ScopeLogger("set: %s", property.c_str()); unsigned int prop; PlatformResult status = GetPlatformProperty(type, property, &prop); @@ -615,7 +615,7 @@ PlatformResult CalendarItem::GetLli(calendar_record_h rec, unsigned int property } Date CalendarItem::DateFromJson(const picojson::object& in) { - ScopeLogger("json date " + picojson::value(in).serialize()); + ScopeLogger("json date %s", picojson::value(in).serialize().c_str()); Date date = {(long long int)common::FromJson(in, "UTCTimestamp"), (int)common::FromJson(in, "year"), diff --git a/src/calendar/calendar_manager.cc b/src/calendar/calendar_manager.cc index 4c2edafc..3a6abd50 100644 --- a/src/calendar/calendar_manager.cc +++ b/src/calendar/calendar_manager.cc @@ -162,7 +162,7 @@ PlatformResult CalendarManager::GetCalendar(const JsonObject& args, JsonObject& if (type != calendar_type) { return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Calendar not found", - ("Calendar type doesn't match requested type %s", type)); + ("Calendar type doesn't match requested type %d", type)); } status = CalendarRecord::CalendarToJson(record_ptr.get(), &out); diff --git a/src/common/logger.h b/src/common/logger.h index fd159bb9..93b0ee58 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -233,18 +233,6 @@ class ScopeLogger { public: ScopeLogger(const std::string& f, const std::string& m, int l, const std::string& ex = "") : file_(f), method_(m), extra_(ex) { - LoggerD("%s: %s(%d) > Enter %s", file_.c_str(), method_.c_str(), l, extra_.c_str()); - } - - template - ScopeLogger(const std::string& f, const std::string& m, int l, const std::string& ex, - Args... args) - : file_(f), method_(m), extra_(ex) { -#ifdef TIZEN_DEBUG_ENABLE - __dlog_print(LOG_ID_MAIN, DLOG_DEBUG, LOGGER_TAG, - ("%s: %s(%d) > %s: %s(%d) > Enter " + extra_).c_str(), __MODULE__, __func__, - __LINE__, file_.c_str(), method_.c_str(), l, args...); -#endif } ~ScopeLogger() { @@ -259,9 +247,15 @@ class ScopeLogger { } // common -#define ScopeLogger(EX, args...) \ - const common::ScopeLogger __sl__ { \ - __MODULE__, __func__, __LINE__, EX, ##args \ - } +#ifdef TIZEN_DEBUG_ENABLE +#define ScopeLogger(EX, args...) \ + __dlog_print(LOG_ID_MAIN, DLOG_DEBUG, LOGGER_TAG, \ + "logger.h: ScopeLogger > %s: %s(%d) > Enter " EX, __MODULE__, __func__, __LINE__, \ + ##args); \ + const common::ScopeLogger __sl__{__MODULE__, __func__, __LINE__, EX}; + +#else +#define ScopeLogger(EX, args...) +#endif #endif // COMMON_LOGGER_H_ diff --git a/src/contact/addressbook.cc b/src/contact/addressbook.cc index 447b171d..012e9213 100644 --- a/src/contact/addressbook.cc +++ b/src/contact/addressbook.cc @@ -364,7 +364,7 @@ PlatformResult AddressBookFind(const JsonObject& args, JsonArray& array) { long address_book_id = common::stol(FromJson(args, "addressBookId")); - LoggerD("Searching in address book: %d", address_book_id); + LoggerD("Searching in address book: %ld", address_book_id); ContactSearchEngine engine; if (!IsUnified(address_book_id)) { diff --git a/src/contact/contact_search_engine.cc b/src/contact/contact_search_engine.cc index 2769e2cf..cee971e1 100644 --- a/src/contact/contact_search_engine.cc +++ b/src/contact/contact_search_engine.cc @@ -671,7 +671,7 @@ PlatformResult ContactSearchEngine::GetContacts(Iterator begin, Iterator end, contacts_record_h record = nullptr; int error_code = contacts_db_get_record(_contacts_contact._uri, id, &record); if (CONTACTS_ERROR_NONE != error_code) { - LoggerE("Failed to get contact with ID: %d", id); + LoggerE("Failed to get contact with ID: %ld", static_cast(id)); continue; } @@ -683,7 +683,7 @@ PlatformResult ContactSearchEngine::GetContacts(Iterator begin, Iterator end, error_code = contacts_record_get_int(record, _contacts_contact.address_book_id, &address_book_id); if (CONTACTS_ERROR_NONE != error_code) { - LoggerE("Failed to get address book ID of contact with ID: %d", id); + LoggerE("Failed to get address book ID of contact with ID: %ld", static_cast(id)); continue; } diff --git a/src/exif/exif_information.cc b/src/exif/exif_information.cc index ac3f4ccb..9a07286b 100644 --- a/src/exif/exif_information.cc +++ b/src/exif/exif_information.cc @@ -456,7 +456,7 @@ void ExifInformation::unset(ExifInformationAttribute attribute) { } void ExifInformation::set(std::string attributeName, const picojson::value& v) { - ScopeLogger(attributeName); + ScopeLogger("%s", attributeName.c_str()); switch (str2int(attributeName.c_str())) { case str2int(EI_URI): { diff --git a/src/exif/exif_tag_saver.cc b/src/exif/exif_tag_saver.cc index 7ead3905..0d917669 100644 --- a/src/exif/exif_tag_saver.cc +++ b/src/exif/exif_tag_saver.cc @@ -28,10 +28,10 @@ namespace extension { namespace exif { void ExifTagSaver::removeExifEntryWithTag(const ExifTag tag, ExifData* exif_data) { - ScopeLogger("tag:%d (0x%x)", tag, exif_data); + ScopeLogger("tag: %d (%p)", tag, exif_data); ExifEntry* exif_entry = exif_data_get_entry(exif_data, tag); if (!exif_entry) { - LoggerE("Exif entry with tag:%d (0x%x) is not present", tag, tag); + LoggerE("Exif entry with tag: %d (0x%x) is not present", tag, tag); return; } @@ -319,7 +319,7 @@ common::PlatformResult ExifTagSaver::saveGpsLocationToExif(const ExifGPSLocation } ExifEntry* ExifTagSaver::prepareEntry(ExifData* exif_data, ExifTag tag) { - ScopeLogger("tag:%d (0x%x)", tag, exif_data); + ScopeLogger("tag: %d (%p)", tag, exif_data); ExifEntry* exif_entry = exif_data_get_entry(exif_data, tag); if (!exif_entry) { diff --git a/src/exif/rational.cc b/src/exif/rational.cc index 93bf5bd5..987a61b6 100644 --- a/src/exif/rational.cc +++ b/src/exif/rational.cc @@ -44,7 +44,7 @@ Rational::Rational(const ExifRational& exif_rational) } Rational Rational::createFromDouble(const double value, const long precision) { - ScopeLogger("value:%f precision:%d", value, precision); + ScopeLogger("value: %f precision: %ld", value, precision); if (value < 0.0) { LoggerW("Trying to create negative Rational: %f!", value); return Rational(); diff --git a/src/humanactivitymonitor/humanactivitymonitor_manager.cc b/src/humanactivitymonitor/humanactivitymonitor_manager.cc index 10385c68..8e8e58dc 100644 --- a/src/humanactivitymonitor/humanactivitymonitor_manager.cc +++ b/src/humanactivitymonitor/humanactivitymonitor_manager.cc @@ -271,11 +271,11 @@ class HumanActivityMonitorManager::Monitor { class GpsMonitor; explicit Monitor(const std::string& t) : type_(t) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); } virtual ~Monitor() { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); } std::string type() const { @@ -287,7 +287,7 @@ class HumanActivityMonitorManager::Monitor { } PlatformResult SetListener(JsonCallback callback, const picojson::value& args) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); auto result = IsSupported(); if (!result) { @@ -304,7 +304,7 @@ class HumanActivityMonitorManager::Monitor { } PlatformResult UnsetListener() { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); auto result = IsSupported(); if (!result) { @@ -321,7 +321,7 @@ class HumanActivityMonitorManager::Monitor { } PlatformResult GetData(picojson::value* data) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); auto result = IsSupported(); if (!result) { @@ -332,7 +332,7 @@ class HumanActivityMonitorManager::Monitor { } PlatformResult StartDataRecorder(int interval, int retention_period) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); auto result = IsSupported(); if (!result) { @@ -343,13 +343,13 @@ class HumanActivityMonitorManager::Monitor { } PlatformResult StopDataRecorder() { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return StopDataRecorderImpl(); } PlatformResult ReadRecorderData(picojson::array* data, const picojson::value& query) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); auto result = IsSupported(); if (!result) { @@ -361,44 +361,44 @@ class HumanActivityMonitorManager::Monitor { protected: virtual PlatformResult IsSupportedImpl(bool* supported) const { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); *supported = false; return PlatformResult(ErrorCode::NO_ERROR); } virtual PlatformResult SetListenerImpl(const picojson::value& args) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "NOT_SUPPORTED_ERR"); } virtual PlatformResult UnsetListenerImpl() { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "NOT_SUPPORTED_ERR"); } virtual PlatformResult GetDataImpl(picojson::value* data) const { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "NOT_SUPPORTED_ERR"); } virtual PlatformResult StartDataRecorderImpl(int interval, int retention_period) const { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "NOT_SUPPORTED_ERR"); } virtual PlatformResult StopDataRecorderImpl() const { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "NOT_SUPPORTED_ERR"); } virtual PlatformResult ReadRecorderDataImpl(picojson::array* data, const picojson::value& query) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "NOT_SUPPORTED_ERR"); } public: PlatformResult IsSupported() { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (!is_supported_) { bool is_supported = false; @@ -427,17 +427,17 @@ class HumanActivityMonitorManager::Monitor::GestureMonitor : public HumanActivityMonitorManager::Monitor { public: explicit GestureMonitor(const std::string& t) : Monitor(t), handle_(nullptr) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); } virtual ~GestureMonitor() override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); UnsetListenerImpl(); } protected: virtual PlatformResult IsSupportedImpl(bool* s) const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); bool supported = false; @@ -459,7 +459,7 @@ class HumanActivityMonitorManager::Monitor::GestureMonitor } virtual PlatformResult SetListenerImpl(const picojson::value&) override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (!handle_) { int ret = gesture_create(&handle_); @@ -482,7 +482,7 @@ class HumanActivityMonitorManager::Monitor::GestureMonitor } virtual PlatformResult UnsetListenerImpl() override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (handle_) { int ret = gesture_stop_recognition(handle_); @@ -538,17 +538,17 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor converter_(c), converter_recorded_(r), recorded_data_(nullptr) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); } virtual ~SensorMonitor() override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); UnsetListenerImpl(); } protected: virtual PlatformResult IsSupportedImpl(bool* s) const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); bool supported = false; @@ -564,7 +564,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor } virtual PlatformResult SetListenerImpl(const picojson::value& args) override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (!handle_) { sensor_h sensor_handle = nullptr; @@ -617,7 +617,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor } virtual PlatformResult UnsetListenerImpl() override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (handle_) { int ret = sensor_listener_stop(handle_); @@ -648,7 +648,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor } virtual PlatformResult GetDataImpl(picojson::value* data) const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (!handle_) { return LogAndCreateResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR, "SERVICE_NOT_AVAILABLE_ERR"); @@ -679,7 +679,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor } virtual PlatformResult StartDataRecorderImpl(int interval, int retention_period) const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); sensor_recorder_option_h option = nullptr; @@ -710,7 +710,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor } virtual PlatformResult StopDataRecorderImpl() const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); int ret = sensor_recorder_stop(sensor_); if (SENSOR_ERROR_NONE != ret) { @@ -724,7 +724,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor virtual PlatformResult ReadRecorderDataImpl(picojson::array* data, const picojson::value& query) override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); std::lock_guard lock(mutex_); this->recorded_data_ = data; @@ -879,17 +879,17 @@ class HumanActivityMonitorManager::Monitor::GpsMonitor : public HumanActivityMonitorManager::Monitor { public: explicit GpsMonitor(const std::string& t) : Monitor(t), handle_(nullptr) { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); } virtual ~GpsMonitor() override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); UnsetListenerImpl(); } protected: virtual PlatformResult IsSupportedImpl(bool* s) const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); int ret = 0; ret = system_info_get_platform_bool("http://tizen.org/feature/location.batch", s); @@ -902,7 +902,7 @@ class HumanActivityMonitorManager::Monitor::GpsMonitor } virtual PlatformResult SetListenerImpl(const picojson::value& args) override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); int ret = 0; @@ -959,7 +959,7 @@ class HumanActivityMonitorManager::Monitor::GpsMonitor } virtual PlatformResult UnsetListenerImpl() override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (handle_) { int ret = location_manager_stop_batch(handle_); @@ -991,7 +991,7 @@ class HumanActivityMonitorManager::Monitor::GpsMonitor } virtual PlatformResult GetDataImpl(picojson::value* data) const override { - ScopeLogger(type()); + ScopeLogger("type %s", type().c_str()); if (!handle_) { return LogAndCreateResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR, "SERVICE_NOT_AVAILABLE_ERR"); diff --git a/src/mediacontroller/mediacontroller_client.cc b/src/mediacontroller/mediacontroller_client.cc index 99ca583e..e6597e51 100644 --- a/src/mediacontroller/mediacontroller_client.cc +++ b/src/mediacontroller/mediacontroller_client.cc @@ -463,7 +463,7 @@ void MediaControllerClient::OnMetadataUpdate(const char* server_name, mc_metadat picojson::value metadata = picojson::value(picojson::object()); PlatformResult result = Types::ConvertMetadata(metadata_h, &metadata.get()); if (!result) { - LoggerE("ConvertMetadata failed, error: ", result.message().c_str()); + LoggerE("ConvertMetadata failed, error: %s", result.message().c_str()); return; } diff --git a/src/mediacontroller/mediacontroller_server.cc b/src/mediacontroller/mediacontroller_server.cc index 0c4d811c..66c6b3a9 100644 --- a/src/mediacontroller/mediacontroller_server.cc +++ b/src/mediacontroller/mediacontroller_server.cc @@ -212,7 +212,7 @@ void MediaControllerServer::OnCommandReceived(const char* client_name, const cha std::string err; picojson::parse(data, data_str, data_str + strlen(data_str), &err); if (!err.empty()) { - LoggerE("Failed to parse bundle data: %d", err); + LoggerE("Failed to parse bundle data: %s", err.c_str()); return; } diff --git a/src/messaging/DBus/MessageProxy.cpp b/src/messaging/DBus/MessageProxy.cpp index 30e17b5f..ffe8f4b8 100644 --- a/src/messaging/DBus/MessageProxy.cpp +++ b/src/messaging/DBus/MessageProxy.cpp @@ -35,7 +35,7 @@ MessageProxy::MessageProxy(EmailManager& manager) : common::dbus::Proxy(kDBusPathEmailStorageChange, kDBusIfaceEmailStorageChange, kDBusNameSignalEmail, kDBusPathEmailStorageChange, kDBusIfaceEmailStorageChange), - email_manager_(manager) { + email_manager_(manager) { ScopeLogger(); } @@ -97,7 +97,7 @@ void MessageProxy::signalCallback(GDBusConnection* connection, const gchar* send LoggerD("Unrecognized status: %d", status); } if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); } g_free(name); } diff --git a/src/messaging/MsgCommon/AbstractFilter.cpp b/src/messaging/MsgCommon/AbstractFilter.cpp index 3f30d4d1..b0365810 100644 --- a/src/messaging/MsgCommon/AbstractFilter.cpp +++ b/src/messaging/MsgCommon/AbstractFilter.cpp @@ -176,8 +176,9 @@ bool FilterUtils::isTimeStampInRange(const time_t& time_stamp, tizen::AnyPtr& in bool is_in_range = FilterUtils::isBetweenTimeRange(time_stamp, from_time, to_time); - LoggerD("%d is%s in time range <%d, %d>", time_stamp, (is_in_range ? "" : " NOT"), from_time, - to_time); + LoggerD("%lld is%s in time range <%lld, %lld>", static_cast(time_stamp), + (is_in_range ? "" : " NOT"), static_cast(from_time), + static_cast(to_time)); return is_in_range; } diff --git a/src/messaging/change_listener_container.cc b/src/messaging/change_listener_container.cc index b0824460..bd764ddb 100644 --- a/src/messaging/change_listener_container.cc +++ b/src/messaging/change_listener_container.cc @@ -58,12 +58,12 @@ class ChangeListenerContainer::ChangeListeners { for (auto& it : groups_) { if (it.second->Remove(id)) { - LoggerD("Listener with id: %d removed from group: %d", id, it.first); + LoggerD("Listener with id: %ld removed from group: %d", id, it.first); return; } } - LoggerW("WatchId %d not found", id); + LoggerW("WatchId %ld not found", id); } template @@ -155,11 +155,11 @@ class ChangeListenerContainer::ChangeListeners { bool ret = false; if (true == (ret = message_callbacks_.Remove(id))) { - LoggerD("Message listener with id: %d removed", id); + LoggerD("Message listener with id: %ld removed", id); } else if (true == (ret = conversation_callbacks_.Remove(id))) { - LoggerD("Conversation listener with id: %d removed", id); + LoggerD("Conversation listener with id: %ld removed", id); } else if (true == (ret = folder_callbacks_.Remove(id))) { - LoggerD("Folder listener with id: %d removed", id); + LoggerD("Folder listener with id: %ld removed", id); } return ret; diff --git a/src/messaging/email_manager.cc b/src/messaging/email_manager.cc index 9a80c0db..0654d6a4 100644 --- a/src/messaging/email_manager.cc +++ b/src/messaging/email_manager.cc @@ -925,7 +925,7 @@ void EmailManager::removeMessages(MessagesCallbackUserData* callback) { PlatformResult ret = RemoveMessagesPlatform(callback); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); callback->SetError(ret); removeEmailCompleteCB(callback); } @@ -1003,7 +1003,7 @@ void EmailManager::updateMessages(MessagesCallbackUserData* callback) { PlatformResult ret = UpdateMessagesPlatform(callback); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); callback->SetError(ret); } @@ -1071,7 +1071,7 @@ void EmailManager::findMessages(FindMsgCallbackUserData* callback) { PlatformResult ret = FindMessagesPlatform(callback); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); callback->SetError(ret); } @@ -1117,7 +1117,7 @@ PlatformResult EmailManager::FindConversationsPlatform(ConversationCallbackData* PlatformResult ret = MessageConversation::convertEmailConversationToObject( conversationsInfo.at(i).id, &conversation); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); return ret; } conversation->setUnreadMessages(conversationsInfo.at(i).unreadMessages); @@ -1137,7 +1137,7 @@ void EmailManager::findConversations(ConversationCallbackData* callback) { PlatformResult ret = FindConversationsPlatform(callback); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); callback->SetError(ret); } @@ -1256,7 +1256,7 @@ void EmailManager::findFolders(FoldersCallbackData* callback) { PlatformResult ret = FindFoldersPlatform(callback); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); callback->SetError(ret); } @@ -1338,7 +1338,7 @@ void EmailManager::removeConversations(ConversationCallbackData* callback) { PlatformResult ret = RemoveConversationsPlatform(callback); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), (ret.message()).c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), (ret.message()).c_str()); callback->SetError(ret); } diff --git a/src/messaging/message.cc b/src/messaging/message.cc index d439357f..ca7b00e3 100644 --- a/src/messaging/message.cc +++ b/src/messaging/message.cc @@ -1176,7 +1176,8 @@ PlatformResult Message::setMMSBodyAndAttachmentsFromStruct(Message* message, msg LoggerD("Loaded body: %s", message->getBody()->getPlainBody().c_str()); } else { - LoggerE("Unhandled error: %d (%s)!", ret.error_code(), ret.message().c_str()); + LoggerE("Unhandled error: %d (%s)!", static_cast(ret.error_code()), + ret.message().c_str()); LoggerD("[p:%d, m:%d] body is not set", p, m); } } else { @@ -1670,7 +1671,7 @@ bool Message::isMatchingAttribute(const std::string& attribute_name, bool Message::isMatchingAttributeRange(const std::string& attribute_name, AnyPtr initial_value, AnyPtr end_value) const { - ScopeLogger(attribute_name); + ScopeLogger("attribute name: %s", attribute_name.c_str()); using namespace MESSAGE_FILTER_ATTRIBUTE; if (TIMESTAMP == attribute_name) { diff --git a/src/messaging/message_conversation.cc b/src/messaging/message_conversation.cc index 5d1ea2cd..3937eb45 100644 --- a/src/messaging/message_conversation.cc +++ b/src/messaging/message_conversation.cc @@ -473,7 +473,7 @@ bool MessageConversation::isMatchingAttribute(const std::string& attribute_name, bool MessageConversation::isMatchingAttributeRange(const std::string& attribute_name, AnyPtr initial_value, AnyPtr end_value) const { - ScopeLogger("attribute_name: " + attribute_name); + ScopeLogger("attribute_name: %s", attribute_name.c_str()); using namespace CONVERSATION_FILTER_ATTRIBUTE; diff --git a/src/messaging/message_service_email.cc b/src/messaging/message_service_email.cc index 9a8a8748..ac153125 100644 --- a/src/messaging/message_service_email.cc +++ b/src/messaging/message_service_email.cc @@ -47,7 +47,7 @@ static gboolean sendMessageTask(void* data) { auto ret = callback->getEmailManager().sendMessage(callback); if (!ret) { - LoggerE("Error: %d - %s", ret.error_code(), ret.message().c_str()); + LoggerE("Error: %d - %s", static_cast(ret.error_code()), ret.message().c_str()); } return FALSE; @@ -116,7 +116,7 @@ static gboolean loadMessageAttachmentTask(void* data) { const auto ret = callback->getEmailManager().loadMessageAttachment(callback); if (!ret) { - LoggerE("Error: %d - %s", ret.error_code(), ret.message().c_str()); + LoggerE("Error: %d - %s", static_cast(ret.error_code()), ret.message().c_str()); } } } else { diff --git a/src/messaging/message_service_short_msg.cc b/src/messaging/message_service_short_msg.cc index a5ca744a..235b4831 100644 --- a/src/messaging/message_service_short_msg.cc +++ b/src/messaging/message_service_short_msg.cc @@ -54,7 +54,7 @@ static gboolean sendMessageThread(void* data) { auto ret = callback->getShortMsgManager().sendMessage(callback); if (!ret) { - LoggerE("Error: %d - %s", ret.error_code(), ret.message().c_str()); + LoggerE("Error: %d - %s", static_cast(ret.error_code()), ret.message().c_str()); } return FALSE; diff --git a/src/messaging/messages_change_callback.cc b/src/messaging/messages_change_callback.cc index d476d9c5..e0567dcd 100644 --- a/src/messaging/messages_change_callback.cc +++ b/src/messaging/messages_change_callback.cc @@ -81,17 +81,17 @@ MessagePtrVector MessagesChangeCallback::filterMessages(tizen::AbstractFilterPtr } LoggerD("[%d] is Message(%p) {", i, message.get()); - LoggerD("[%d] messageId: %d", i, message->getId()); - LoggerD("[%d] message subject: %s", i, message->getSubject().c_str()); - LoggerD("[%d] from: %s", i, message->getFrom().c_str()); + LoggerD("messageId: %d", message->getId()); + LoggerD("message subject: %s", message->getSubject().c_str()); + LoggerD("from: %s", message->getFrom().c_str()); if (message->getBody()) { const std::string& pBody = message->getBody()->getPlainBody(); - LoggerD("[%d] message plainBody: %s", i, limitedString(pBody).c_str()); + LoggerD("message plainBody: %s", limitedString(pBody).c_str()); } - LoggerD("[%d] matched filter: %s", i, matched ? "YES" : "NO"); - LoggerD("[%d] }"); + LoggerD("matched filter: %s", matched ? "YES" : "NO"); + LoggerD("}"); } LoggerD("returning matching %d of %d messages", filtered_messages.size(), diff --git a/src/messaging/messaging_database_manager.cc b/src/messaging/messaging_database_manager.cc index 4e4edffc..f0df6e6d 100644 --- a/src/messaging/messaging_database_manager.cc +++ b/src/messaging/messaging_database_manager.cc @@ -203,9 +203,9 @@ msg_error_t MessagingDatabaseManager::connect() { return MSG_ERR_DB_CONNECT; } - LoggerD("DB connecting success: [%d]", sqlHandle); + LoggerD("DB connecting success: [%p]", sqlHandle); } else { - LoggerD("DB connection exists: [%d]", sqlHandle); + LoggerD("DB connection exists: [%p]", sqlHandle); } return MSG_SUCCESS; @@ -474,7 +474,7 @@ PlatformResult MessagingDatabaseManager::getAttributeFilterQuery(AbstractFilterP break; default: - LoggerE("Unexpected folder ID: %d", folder_id); + LoggerE("Unexpected folder ID: %ld", static_cast(folder_id)); folder_id = -1; break; } diff --git a/src/messaging/short_message_manager.cc b/src/messaging/short_message_manager.cc index 6007a592..050971f5 100644 --- a/src/messaging/short_message_manager.cc +++ b/src/messaging/short_message_manager.cc @@ -431,7 +431,7 @@ PlatformResult ShortMsgManager::callProperEventMessages(EventMessages* event, updated_conv.push_back(cur_conv); } - LoggerD("%s conversation with id:%d last_msg_id:d", (new_conv ? "ADDED" : "UPDATED"), + LoggerD("%s conversation with id:%d last_msg_id:%d", (new_conv ? "ADDED" : "UPDATED"), cur_conv->getConversationId(), cur_conv->getLastMessageId()); } @@ -675,7 +675,7 @@ void ShortMsgManager::addDraftMessage(MessageCallbackUserData* callback) { PlatformResult ret = addDraftMessagePlatform(message); if (ret.IsError()) { - LoggerE("%d (%s)", ret.error_code(), ret.message().c_str()); + LoggerE("%d (%s)", static_cast(ret.error_code()), ret.message().c_str()); callback->SetError(ret); } } @@ -892,7 +892,8 @@ void ShortMsgManager::findMessages(FindMsgCallbackUserData* callback) { PlatformResult ret = MessagingDatabaseManager::getInstance().findShortMessages(callback, &messagesIds); if (ret.IsError()) { - LoggerE("Failed to find short message: %s (%d)", ret.message().c_str(), ret.error_code()); + LoggerE("Failed to find short message: %s (%d)", ret.message().c_str(), + static_cast(ret.error_code())); callback->SetError(ret); } @@ -1090,7 +1091,7 @@ void ShortMsgManager::removeConversations(ConversationCallbackData* callback) { "saved MessageConversation(%p) with conv_id:%d", conv_index, msg_index, cur_msg_id, conv.get(), conv_id); } else { - LoggerE("[%d] Couldn't get msg_id, error: %d!", error); + LoggerE("[%d] Couldn't get msg_id, error: %s!", error, get_error_message(error)); } } } else { diff --git a/src/nfc/nfc_adapter.cc b/src/nfc/nfc_adapter.cc index cad6baab..0c81b296 100644 --- a/src/nfc/nfc_adapter.cc +++ b/src/nfc/nfc_adapter.cc @@ -846,7 +846,7 @@ PlatformResult NFCAdapter::TagNDEFSizeGetter(int /*tag_id*/, unsigned int* size) int err = nfc_tag_get_ndef_size(m_last_tag_handle, size); if (NFC_ERROR_NONE != err) { - LoggerE("Failed to get tag NDEF size: %d, %s", err); + LoggerE("Failed to get tag NDEF size: %d, %s", err, get_error_message(err)); return NFCUtil::CodeToResult(err, "Failed to get tag NDEF size"); } return PlatformResult(ErrorCode::NO_ERROR); @@ -1259,7 +1259,7 @@ PlatformResult NFCAdapter::GetCachedMessage(picojson::object& out) { PlatformResult ret = NFCMessageUtils::ReportNdefMessageFromData(raw_data, size, out); free(raw_data); if (ret.IsError()) { - LoggerE("Error: %d", ret.message().c_str()); + LoggerE("Error: %s", ret.message().c_str()); NFCMessageUtils::RemoveMessageHandle(message_handle); return ret; } diff --git a/src/notification/notification_manager.cc b/src/notification/notification_manager.cc index a7b3418d..8d0a0e26 100644 --- a/src/notification/notification_manager.cc +++ b/src/notification/notification_manager.cc @@ -236,7 +236,7 @@ PlatformResult NotificationManager::PlayLEDCustomEffect(const picojson::object& ret = device_led_play_custom(timeOn, timeOff, color, platformFlags); if (DEVICE_ERROR_NONE != ret) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot play LED custom effect", - ("Cannot play LED custom effect: ", ret)); + ("Cannot play LED custom effect: %d", ret)); } return PlatformResult(ErrorCode::NO_ERROR); @@ -248,7 +248,7 @@ PlatformResult NotificationManager::StopLEDCustomEffect() { int ret = device_led_stop_custom(); if (DEVICE_ERROR_NONE != ret) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot stop LED custom effect", - ("Cannot stop LED custom effect: ", ret)); + ("Cannot stop LED custom effect: %d", ret)); } return PlatformResult(ErrorCode::NO_ERROR); diff --git a/src/radio/radio_manager.cc b/src/radio/radio_manager.cc index e33cd4cf..2e9ea1ea 100644 --- a/src/radio/radio_manager.cc +++ b/src/radio/radio_manager.cc @@ -353,7 +353,7 @@ FMRadioManager::~FMRadioManager() { } PlatformResult FMRadioManager::Start(double frequency) { - ScopeLogger("freq: %d", frequency); + ScopeLogger("freq: %lf", frequency); radio_state_e state; const auto err = radio_get_state(radio_instance_, &state); diff --git a/src/sensor/sensor_service.cc b/src/sensor/sensor_service.cc index 8c652201..1dcc339d 100644 --- a/src/sensor/sensor_service.cc +++ b/src/sensor/sensor_service.cc @@ -284,7 +284,7 @@ SensorData::SensorData(SensorInstance& instance, sensor_type_e type_enum, const } SensorData::~SensorData() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); if (listener_) { sensor_destroy_listener(listener_); @@ -337,7 +337,7 @@ void SensorData::SensorCallback(sensor_h sensor, sensor_event_s* event, void* us } PlatformResult SensorData::CheckInitialization() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); std::lock_guard lock(initialization_mutex_); if (!handle_) { @@ -360,7 +360,7 @@ PlatformResult SensorData::CheckInitialization() { } PlatformResult SensorData::IsSupported(bool* supported) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); if (!is_supported_) { bool is_supported = false; @@ -377,7 +377,7 @@ PlatformResult SensorData::IsSupported(bool* supported) { } PlatformResult SensorData::IsSupportedImpl(bool* supported) const { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); bool is_supported = false; int ret = sensor_is_supported(type_enum_, &is_supported); @@ -392,7 +392,7 @@ PlatformResult SensorData::IsSupportedImpl(bool* supported) const { } bool SensorData::is_supported() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); if (!is_supported_) { bool is_supported = false; @@ -408,7 +408,7 @@ bool SensorData::is_supported() { } bool SensorData::UpdateEvent(sensor_event_s* event) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); if (comparator_(&previous_event_, event, sensor_value_count_)) { // previous and current events are the same -> no update @@ -444,7 +444,7 @@ PlatformResult SensorData::AddDelayedStartSuccessCb(const std::function& PlatformResult SensorData::Start( const std::shared_ptr& result, const std::function&)>& report_result) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); auto res = CheckInitialization(); if (!res) { @@ -484,7 +484,7 @@ PlatformResult SensorData::Start( } PlatformResult SensorData::Stop() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); auto res = CheckInitialization(); @@ -513,7 +513,7 @@ PlatformResult SensorData::Stop() { } PlatformResult SensorData::SetChangeListener(unsigned int interval, unsigned int batch_latency) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); auto res = CheckInitialization(); @@ -544,7 +544,7 @@ PlatformResult SensorData::SetChangeListener(unsigned int interval, unsigned int } PlatformResult SensorData::UnsetChangeListener() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); auto res = CheckInitialization(); @@ -568,7 +568,7 @@ PlatformResult SensorData::UnsetChangeListener() { } PlatformResult SensorData::GetSensorData(picojson::object* data) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); auto res = CheckInitialization(); @@ -590,7 +590,7 @@ PlatformResult SensorData::GetSensorData(picojson::object* data) { } PlatformResult SensorData::GetHardwareInfo(picojson::object* data) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); auto res = CheckInitialization(); @@ -629,42 +629,42 @@ PlatformResult SensorData::GetHardwareInfo(picojson::object* data) { int ret = sensor_get_name(handle_, &name); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_name error code: %d", &ret); + LoggerE("Failed to sensor_get_name error code: %d", ret); return native_result(ret); } ret = sensor_get_vendor(handle_, &vendor); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_vendor error code: %d", &ret); + LoggerE("Failed to sensor_get_vendor error code: %d", ret); return native_result(ret); } ret = sensor_get_type(handle_, &type); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_type error code: %d", &ret); + LoggerE("Failed to sensor_get_type error code: %d", ret); return native_result(ret); } ret = sensor_get_min_range(handle_, &min_range); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_min_range error code: %d", &ret); + LoggerE("Failed to sensor_get_min_range error code: %d", ret); return native_result(ret); } ret = sensor_get_max_range(handle_, &max_range); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_max_range error code: %d", &ret); + LoggerE("Failed to sensor_get_max_range error code: %d", ret); return native_result(ret); } ret = sensor_get_resolution(handle_, &resolution); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_resolution error code: %d", &ret); + LoggerE("Failed to sensor_get_resolution error code: %d", ret); return native_result(ret); } ret = sensor_get_min_interval(handle_, &min_interval); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_min_interval error code: %d", &ret); + LoggerE("Failed to sensor_get_min_interval error code: %d", ret); return native_result(ret); } ret = sensor_get_max_batch_count(handle_, &max_batch_count); if (ret != SENSOR_ERROR_NONE) { - LoggerE("Failed to sensor_get_max_batch_count error code: %d", &ret); + LoggerE("Failed to sensor_get_max_batch_count error code: %d", ret); return native_result(ret); } @@ -710,7 +710,7 @@ class HrmSensorData : public SensorData { HrmSensorData::HrmSensorData(SensorInstance& instance) : SensorData(instance, SENSOR_CUSTOM, "HRM_RAW", 1) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); // For amount of retrieved values from sensors please refer to native guides. AddSensor(new SensorData(instance, SENSOR_HRM_LED_IR, "LED_IR", 1)); AddSensor(new SensorData(instance, SENSOR_HRM_LED_RED, "LED_RED", 1)); @@ -718,16 +718,16 @@ HrmSensorData::HrmSensorData(SensorInstance& instance) } HrmSensorData::~HrmSensorData() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); } void HrmSensorData::AddSensor(SensorData* sensor) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); hrm_sensors_.insert(std::make_pair(sensor->type(), std::shared_ptr(sensor))); } PlatformResult HrmSensorData::CallMember(PlatformResult (SensorData::*member)()) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); bool is_any_supported = false; for (const auto& sensor : hrm_sensors_) { if (sensor.second->is_supported()) { @@ -751,7 +751,7 @@ PlatformResult HrmSensorData::CallMember( const std::function&)>&), const std::shared_ptr& result, const std::function&)>& work) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); bool is_any_supported = false; for (const auto& sensor : hrm_sensors_) { if (sensor.second->is_supported()) { @@ -770,7 +770,7 @@ PlatformResult HrmSensorData::CallMember( } PlatformResult HrmSensorData::IsSupportedImpl(bool* supported) const { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); bool result = false; for (const auto& sensor : hrm_sensors_) { @@ -790,17 +790,17 @@ PlatformResult HrmSensorData::IsSupportedImpl(bool* supported) const { PlatformResult HrmSensorData::Start( const std::shared_ptr& result, const std::function&)>& work) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); return CallMember(&SensorData::Start, result, work); } PlatformResult HrmSensorData::Stop() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); return CallMember(&SensorData::Stop); } PlatformResult HrmSensorData::SetChangeListener(unsigned int interval, unsigned int batch_latency) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); for (const auto& sensor : hrm_sensors_) { if (sensor.second->is_supported()) { auto res = sensor.second->SetChangeListener(interval, batch_latency); @@ -813,12 +813,12 @@ PlatformResult HrmSensorData::SetChangeListener(unsigned int interval, unsigned } PlatformResult HrmSensorData::UnsetChangeListener() { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); return CallMember(&SensorData::UnsetChangeListener); } PlatformResult HrmSensorData::GetSensorData(picojson::object* data) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); for (const auto& sensor : hrm_sensors_) { if (sensor.second->is_supported()) { // HRMRawSensor.getHRMRawSensorData() can return only one value, @@ -840,7 +840,7 @@ PlatformResult HrmSensorData::GetSensorData(picojson::object* data) { } PlatformResult HrmSensorData::GetHardwareInfo(picojson::object* data) { - ScopeLogger(type_to_string_map[type()]); + ScopeLogger("type: %s", type_to_string_map[type()].c_str()); for (const auto& sensor : hrm_sensors_) { if (sensor.second->is_supported()) { return sensor.second->GetHardwareInfo(data); diff --git a/src/sound/sound_manager.cc b/src/sound/sound_manager.cc index 31744363..8c98163d 100644 --- a/src/sound/sound_manager.cc +++ b/src/sound/sound_manager.cc @@ -274,7 +274,7 @@ PlatformResult SoundManager::SetVolume(const picojson::object& args) { auto it = max_volume_map_.find(sound_type); if (it == max_volume_map_.end()) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to find maxVolume", - ("Failed to find maxVolume of type: %d", type.c_str())); + ("Failed to find maxVolume of type: %s", type.c_str())); } int max_volume = it->second;