[Common] Preventing logger from runtime format definition 59/162359/2
authorPiotr Kosko <p.kosko@samsung.com>
Mon, 27 Nov 2017 07:07:18 +0000 (08:07 +0100)
committerPiotr Kosko <p.kosko@samsung.com>
Fri, 1 Dec 2017 12:22:27 +0000 (13:22 +0100)
[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 <p.kosko@samsung.com>
30 files changed:
src/alarm/alarm_manager.cc
src/archive/archive_callback_data.cc
src/calendar/calendar.cc
src/calendar/calendar_item.cc
src/calendar/calendar_manager.cc
src/common/logger.h
src/contact/addressbook.cc
src/contact/contact_search_engine.cc
src/exif/exif_information.cc
src/exif/exif_tag_saver.cc
src/exif/rational.cc
src/humanactivitymonitor/humanactivitymonitor_manager.cc
src/mediacontroller/mediacontroller_client.cc
src/mediacontroller/mediacontroller_server.cc
src/messaging/DBus/MessageProxy.cpp
src/messaging/MsgCommon/AbstractFilter.cpp
src/messaging/change_listener_container.cc
src/messaging/email_manager.cc
src/messaging/message.cc
src/messaging/message_conversation.cc
src/messaging/message_service_email.cc
src/messaging/message_service_short_msg.cc
src/messaging/messages_change_callback.cc
src/messaging/messaging_database_manager.cc
src/messaging/short_message_manager.cc
src/nfc/nfc_adapter.cc
src/notification/notification_manager.cc
src/radio/radio_manager.cc
src/sensor/sensor_service.cc
src/sound/sound_manager.cc

index 8ca564bc37dfd973595837f02230f6a4628d380d..2588fa25f2060442d1dd94f5a1382e2167a19d7d 100644 (file)
@@ -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<int>(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 <stdio.h>
 
 void AlarmManager::GetAll(const picojson::value& args, picojson::object& out) {
   ScopeLogger();
-
   std::vector<int> 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<double>()) {
index f761270b9ccf1104a1e425eeab28bdc294c1922b..8924616433e81bec5db6b439e9c87e2802202399 100644 (file)
@@ -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<int>(err_code));
   // store only first error
   if (!m_is_error) {
     m_err_code = err_code;
index ef161c0e4314cf78af788903a1795d6a5cf48491..556274dcd05c4433ff726eded6cb4d9d58aee097 100644 (file)
@@ -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<int>(calType)));
         }
       }
       intermediate_filters.pop_back();
index 7e209b4407bd1fdec38b2c3e9ead0e36971265a4..d42f743f96cba6fcdd6eeec011ae743ba585dca3 100644 (file)
@@ -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<double>(in, "UTCTimestamp"),
                (int)common::FromJson<double>(in, "year"),
index 4c2edafcfcbb301a3b5dc5f179d062c28eeb3a88..3a6abd50fcd7b76e2f3ec1239dac5e5024cfc148 100644 (file)
@@ -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);
index fd159bb910dfe2e8dab6ecd10033d9750fe38b18..93b0ee58f6582dd3c90b9ca42754e1e8db5fd1d3 100644 (file)
@@ -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 <typename... Args>
-  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_
index 447b171d06dc9cc169857efe223fe985e47ee4b9..012e9213c60ad65791258cd8a81ddae014d98fb7 100644 (file)
@@ -364,7 +364,7 @@ PlatformResult AddressBookFind(const JsonObject& args, JsonArray& array) {
 
   long address_book_id = common::stol(FromJson<std::string>(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)) {
index 2769e2cf63805ee912a97371dc95c0cbc9328a67..cee971e16008c1b1539b502103ad9baecee49349 100644 (file)
@@ -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<long>(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<long>(id));
         continue;
       }
 
index ac3f4ccbb009ee54ca8cf572beb532b6a3d3378d..9a07286b67495b1be0a4ef9353a17f8071132e6f 100644 (file)
@@ -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): {
index 7ead39056bf5365c22682a059c1fe3001428bf45..0d9176694dddc5f0ffe1820d6d0a58450e03588b 100644 (file)
@@ -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) {
index 93bf5bd577ffeb4309d45933f00728df5dae23e4..987a61b6b9e624b738979c01272a615954bdb4c1 100644 (file)
@@ -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();
index 10385c68f99f8d6ceee3622ec0b7b03ded10e21e..8e8e58dc4a00de44cdf8e4b7cfbbedd68fe2f558 100644 (file)
@@ -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<std::mutex> 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");
index 99ca583e9b602d9ba381a5dbb9f06b28a1e0f680..e6597e5102b809778f62d13e7bdb4380f2e0e4ce 100644 (file)
@@ -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<picojson::object>());
   if (!result) {
-    LoggerE("ConvertMetadata failed, error: ", result.message().c_str());
+    LoggerE("ConvertMetadata failed, error: %s", result.message().c_str());
     return;
   }
 
index 0c4d811c00e405136b7f3bb76d0cebbf6b507b40..66c6b3a9938b640c8f02e8ddc26b4c19c1d99a98 100644 (file)
@@ -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;
   }
 
index 30e17b5fae03f497af4a410ad84d8f1d45e840e2..ffe8f4b87b2839d7113ff9ca262c75c4ebfbb143 100644 (file)
@@ -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<int>(ret.error_code()), (ret.message()).c_str());
   }
   g_free(name);
 }
index 3f30d4d1ce4fef8eae237990080115944fc0d4ea..b0365810aa2de5e090abf35a065dec74f114a134 100644 (file)
@@ -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<long long>(time_stamp),
+          (is_in_range ? "" : " NOT"), static_cast<long long>(from_time),
+          static_cast<long long>(to_time));
 
   return is_in_range;
 }
index b0824460bd6897d4cfe373f22e389910e526e256..bd764ddbb7156666a32ff7fc0577827e39cb418d 100644 (file)
@@ -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 <class CallbackType, class EventType>
@@ -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;
index 9a80c0dbca6e45a2722c895dda71d9b02fc60934..0654d6a4200dfeb74546e6ea09e86f8d7acf8688 100644 (file)
@@ -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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(ret.error_code()), (ret.message()).c_str());
     callback->SetError(ret);
   }
 
index d439357f4cd7af6f14f8aed3b90508580df7b710..ca7b00e3966a9018084bc33865c6807da9d19f05 100644 (file)
@@ -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<int>(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) {
index 5d1ea2cd80c0805c95730711cebaa52d0cb83050..3937eb45f949d90d3fc1a26f5e6bbedfa9d115e3 100644 (file)
@@ -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;
 
index 9a8a874836871ffd1c7fac07278caab50565fce0..ac15312536dfc8cdb4ecfcb272927f91ed3c0190 100644 (file)
@@ -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<int>(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<int>(ret.error_code()), ret.message().c_str());
       }
     }
   } else {
index a5ca744a3d1cf7d88d77207d7547b8c9889c115d..235b4831235c3631e509f1c3be61d5e2064177c1 100644 (file)
@@ -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<int>(ret.error_code()), ret.message().c_str());
   }
 
   return FALSE;
index d476d9c55d2b319f137a74b2a2fdbd534fa8e252..e0567dcd014016c229018cb39186695362b490ec 100644 (file)
@@ -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(),
index 4e4edffcf30583cfeafc3ddc91e7dfd89e21af88..f0df6e6d5c31c465ea316887464491edd04429bf 100644 (file)
@@ -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<long>(folder_id));
           folder_id = -1;
           break;
       }
index 6007a5929725371eb4f00146a7fe909b8e644ac5..050971f500f4ee1c22e8e8e948e3f9c08e4371d6 100644 (file)
@@ -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<int>(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<int>(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 {
index cad6baab343e98ed4ad055d3c188ba1d9c5520b9..0c81b296b34f51c037199ff72e20335fd8e23c8f 100644 (file)
@@ -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;
   }
index a7b3418d253920851673ce10c563bb08c19b2cf7..8d0a0e26d58523a9b4e15190a8033149bc3ae4d2 100644 (file)
@@ -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);
index e33cd4cf1be5ea2b0361f91d192df3c7f67a7d62..2e9ea1ea3040594f366d97f95cb731bedba681fc 100644 (file)
@@ -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);
index 8c652201f265a13c96f48a2c6fefe1ad63dc54fb..1dcc339deb061fe33d6d8e671e918e74baa615a4 100644 (file)
@@ -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<std::mutex> 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<void()>&
 PlatformResult SensorData::Start(
     const std::shared_ptr<picojson::value>& result,
     const std::function<void(const std::shared_ptr<picojson::value>&)>& 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<SensorData>(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<void(const std::shared_ptr<picojson::value>&)>&),
     const std::shared_ptr<picojson::value>& result,
     const std::function<void(const std::shared_ptr<picojson::value>&)>& 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<picojson::value>& result,
     const std::function<void(const std::shared_ptr<picojson::value>&)>& 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);
index 317443631d86b07933a04c9830202f98455714b7..8c98163d9b75d33e5f7305a8770cf091dc16f19b 100644 (file)
@@ -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;