Fix Logger to C++ (chromium) style.
authorWonYoung Choi <wy80.choi@samsung.com>
Fri, 8 May 2015 06:26:53 +0000 (15:26 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Fri, 8 May 2015 06:26:53 +0000 (15:26 +0900)
Change-Id: If2fdf52cd890b7a565ffc0b6d5cb4ceb3a51ad25

21 files changed:
src/bundle/extension_client.cc
src/bundle/extension_module.cc
src/bundle/injected_bundle.cc
src/bundle/module_system.cc
src/common/app_control.cc
src/common/application_data.cc
src/common/dbus_client.cc
src/common/dbus_server.cc
src/common/locale_manager.cc
src/common/logger.h
src/common/profiler.cc
src/common/resource_manager.cc
src/extension/extension.cc
src/extension/extension_adapter.cc
src/extension/extension_server.cc
src/runtime/main.cc
src/runtime/native_window.cc
src/runtime/runtime.cc
src/runtime/vibration_manager.cc
src/runtime/web_application.cc
src/runtime/web_view_impl.cc

index 1222d19..500ff83 100755 (executable)
@@ -35,8 +35,8 @@ std::string ExtensionClient::CreateInstance(
       G_VARIANT_TYPE("(s)"));
 
   if (!value) {
-    LoggerE("Failed to create instance for extension %s",
-            extension_name.c_str());
+    LOGGER(ERROR) << "Failed to create instance for extension "
+                  << extension_name;
     return std::string();
   }
 
@@ -57,7 +57,7 @@ void ExtensionClient::DestroyInstance(const std::string& instance_id) {
       G_VARIANT_TYPE("(s)"));
 
   if (!value) {
-    LoggerE("Failed to destroy instance %s", instance_id.c_str());
+    LOGGER(ERROR) << "Failed to destroy instance " << instance_id;
     return;
   }
 
@@ -85,7 +85,7 @@ std::string ExtensionClient::SendSyncMessageToNative(
       G_VARIANT_TYPE("(s)"));
 
   if (!value) {
-    LoggerE("Failed to send synchronous message to ExtensionServer.");
+    LOGGER(ERROR) << "Failed to send synchronous message to ExtensionServer.";
     return std::string();
   }
 
@@ -108,7 +108,7 @@ void ExtensionClient::Initialize(const std::string& uuid) {
         kDBusInterfaceNameForExtension,
         std::bind(&ExtensionClient::HandleSignal, this, _1, _2));
   } else {
-    LoggerE("Failed to connect to the dbus server for Extension.");
+    LOGGER(ERROR) << "Failed to connect to the dbus server for Extension.";
     return;
   }
 
@@ -119,7 +119,7 @@ void ExtensionClient::Initialize(const std::string& uuid) {
       G_VARIANT_TYPE("(a(ssas))"));
 
   if (!value) {
-    LoggerE("Failed to get extension list from ExtensionServer.");
+    LOGGER(ERROR) << "Failed to get extension list from ExtensionServer.";
     return;
   }
 
index c316ef0..ae50939 100644 (file)
@@ -261,8 +261,8 @@ void ExtensionModule::LoadExtensionCode(v8::Handle<v8::Context> context) {
   v8::Handle<v8::Value> result = RunString(wrapped_api_code, &exception);
 
   if (!result->IsFunction()) {
-    LoggerE("Couldn't load JS API code for %s: %s",
-            extension_name_.c_str(), exception.c_str());
+    LOGGER(ERROR) << "Couldn't load JS API code for "
+                  << extension_name_ << " : " << exception;
     return;
   }
   v8::Handle<v8::Function> callable_api_code =
@@ -280,8 +280,8 @@ void ExtensionModule::LoadExtensionCode(v8::Handle<v8::Context> context) {
   try_catch.SetVerbose(true);
   callable_api_code->Call(context->Global(), argc, argv);
   if (try_catch.HasCaught()) {
-    LoggerE("Exception while loading JS API code for %s: %s",
-            extension_name_.c_str(), ExceptionToString(try_catch).c_str());
+    LOGGER(ERROR) << "Exception while loading JS API code for "
+                  << extension_name_ << " : " << ExceptionToString(try_catch);
   }
 }
 
@@ -303,8 +303,8 @@ void ExtensionModule::HandleMessageFromNative(const std::string& msg) {
   v8::TryCatch try_catch;
   message_listener->Call(context->Global(), 1, args);
   if (try_catch.HasCaught())
-    LoggerE("Exception when running message listener: %s",
-            ExceptionToString(try_catch).c_str());
+    LOGGER(ERROR) << "Exception when running message listener: "
+                  << ExceptionToString(try_catch);
 }
 
 // static
@@ -360,7 +360,7 @@ void ExtensionModule::SetMessageListenerCallback(
   }
 
   if (!info[0]->IsFunction() && !info[0]->IsUndefined()) {
-    LoggerE("Trying to set message listener with invalid value.");
+    LOGGER(ERROR) << "Trying to set message listener with invalid value.";
     result.Set(false);
     return;
   }
@@ -384,7 +384,7 @@ ExtensionModule* ExtensionModule::GetExtensionModule(
   v8::Local<v8::Value> module =
       data->Get(v8::String::NewFromUtf8(isolate, kWrtExtensionModule));
   if (module.IsEmpty() || module->IsUndefined()) {
-    LoggerE("Trying to use extension from already destroyed context!");
+    LOGGER(ERROR) << "Trying to use extension from already destroyed context!";
     return NULL;
   }
   // CHECK(module->IsExternal());
index 0c90299..300e7bd 100755 (executable)
@@ -11,7 +11,7 @@
 #include "bundle/extension_renderer_controller.h"
 
 extern "C" void DynamicSetWidgetInfo(int /*widget_id*/) {
-  LoggerD("InjectedBundle::DynamicSetWidgetInfo !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicSetWidgetInfo !!";
 }
 
 extern "C" void DynamicPluginStartSession(int /*widget_id*/,
@@ -21,9 +21,9 @@ extern "C" void DynamicPluginStartSession(int /*widget_id*/,
                                           const char* uuid,
                                           const char* /*theme*/,
                                           const char* base_url) {
-  LoggerD("InjectedBundle::DynamicPluginStartSession !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicPluginStartSession !!";
   if (base_url == NULL || wrt::utils::StartsWith(base_url, "http")) {
-    LoggerD("External url not allowed plugin loading.");
+    LOGGER(ERROR) << "External url not allowed plugin loading.";
     return;
   }
 
@@ -36,7 +36,7 @@ extern "C" void DynamicPluginStartSession(int /*widget_id*/,
 
 extern "C" void DynamicPluginStopSession(
     int /*widget_id*/, v8::Handle<v8::Context> context) {
-  LoggerD("InjectedBundle::DynamicPluginStopSession !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicPluginStopSession !!";
 
   wrt::ExtensionRendererController& controller =
       wrt::ExtensionRendererController::GetInstance();
@@ -45,18 +45,18 @@ extern "C" void DynamicPluginStopSession(
 
 extern "C" void DynamicUrlParsing(
     std::string* old_url, std::string* new_url, int /*widget_id*/) {
-  LoggerD("InjectedBundle::DynamicUrlParsing !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicUrlParsing !!";
   *new_url = *old_url;
 }
 
 extern "C" void DynamicDatabaseAttach(int /*attach*/) {
-  LoggerD("InjectedBundle::DynamicDatabaseAttach !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicDatabaseAttach !!";
 }
 
 extern "C" void DynamicOnIPCMessage(const Ewk_IPC_Wrt_Message_Data& /*data*/) {
-  LoggerD("InjectedBundle::DynamicOnIPCMessage !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicOnIPCMessage !!";
 }
 
 extern "C" void DynamicPreloading() {
-  LoggerD("InjectedBundle::DynamicPreloading !!");
+  LOGGER(DEBUG) << "InjectedBundle::DynamicPreloading !!";
 }
index 7849b5f..fe18b14 100644 (file)
@@ -77,19 +77,19 @@ void ModuleSystem::RegisterExtensionModule(
     const std::vector<std::string>& entry_points) {
   const std::string& extension_name = module->extension_name();
   if (ContainsEntryPoint(extension_name)) {
-    LoggerE("Can't register Extension Module named for extension "
-            "'%s' in the Module System because name was already registered.",
-            extension_name.c_str());
+    LOGGER(ERROR) << "Can't register Extension Module named for extension '"
+                  << extension_name << "' in the Module System because name "
+                  << " was already registered.";
     return;
   }
 
   std::vector<std::string>::const_iterator it = entry_points.begin();
   for (; it != entry_points.end(); ++it) {
     if (ContainsEntryPoint(*it)) {
-      LoggerE("Can't register Extension Module named for extension "
-              "'%s' in the Module System because another extension "
-              "has the entry point '%s'.",
-              extension_name.c_str(), (*it).c_str());
+      LOGGER(ERROR) << "Can't register Extension Module named for extension '"
+                    << extension_name << "' in the Module System because "
+                    << "another extension has the entry point '"
+                    << (*it) << "'.";
       return;
     }
   }
@@ -182,8 +182,8 @@ bool ModuleSystem::SetTrampolineAccessorForEntryPoint(
   v8::Handle<v8::Value> value =
       EnsureTargetObjectForTrampoline(context, path, &error);
   if (value->IsUndefined()) {
-    LoggerE("Error installing trampoline for %s: %s.",
-            entry_point.c_str(), error.c_str());
+    LOGGER(ERROR) << "Error installing trampoline for " << entry_point
+                  << " : " << error;
     return false;
   }
 
@@ -213,8 +213,8 @@ bool ModuleSystem::DeleteAccessorForEntryPoint(
   std::string error;
   v8::Handle<v8::Value> value = GetObjectForPath(context, path, &error);
   if (value->IsUndefined()) {
-    LoggerE("Error retrieving object for %s: %s.",
-            entry_point.c_str(), error.c_str());
+    LOGGER(ERROR) << "Error retrieving object for " << entry_point
+                  << " : " << error;
     return false;
   }
 
@@ -230,7 +230,7 @@ bool ModuleSystem::InstallTrampoline(v8::Handle<v8::Context> context,
   bool ret = SetTrampolineAccessorForEntryPoint(context, entry->name,
                                                 entry_ptr);
   if (!ret) {
-    LoggerE("Error installing trampoline for '%s'.", entry->name.c_str());
+    LOGGER(ERROR) << "Error installing trampoline for " << entry->name;
     return false;
   }
 
@@ -239,7 +239,7 @@ bool ModuleSystem::InstallTrampoline(v8::Handle<v8::Context> context,
     ret = SetTrampolineAccessorForEntryPoint(context, *it, entry_ptr);
     if (!ret) {
       // TODO(vcgomes): Remove already added trampolines when it fails.
-      LoggerE("Error installing trampoline for '%s'.", entry->name.c_str());
+      LOGGER(ERROR) << "Error installing trampoline for " << entry->name;
       return false;
     }
   }
@@ -416,8 +416,8 @@ void ModuleSystem::EnsureExtensionNamespaceIsReadOnly(
   std::string error;
   v8::Handle<v8::Value> value = GetObjectForPath(context, path, &error);
   if (value->IsUndefined()) {
-    LoggerE("Error retrieving object for %s: %s.",
-            extension_name.c_str(), error.c_str());
+    LOGGER(ERROR) << "Error retrieving object for " << extension_name << " : "
+                  << error;
     return;
   }
 
index 1ed073f..fc6f2cc 100755 (executable)
@@ -17,7 +17,7 @@ static bool BundleAddData(bundle* target, const std::string& key,
                           const std::string& value) {
   int result = appsvc_add_data(target, key.c_str(), value.c_str());
   if (result < 0) {
-    LoggerE("BundleAddData : appsvc_add_data fail");
+    LOGGER(ERROR) << "Failed to add data to appsvc.";
     return false;
   } else {
     return true;
@@ -36,7 +36,7 @@ static bool BundleAddDataArray(bundle* target, const std::string& key,
   int result = appsvc_add_data_array(target, key.c_str(),
                                      v.data(), n);
   if (result < 0) {
-    LoggerE("BundleAddDataArray appsvc_add_data_array fail");
+    LOGGER(ERROR) << "Failed to add an array of data to appsvc.";
     return false;
   } else {
     return true;
@@ -172,7 +172,7 @@ bool AppControl::Reply(const std::map<std::string,
   bundle* result;
   if (appsvc_create_result_bundle(app_control_bundle_,
                                   &result) != APPSVC_RET_OK) {
-    LoggerE("AppControl::Reply Fail : fail to create result bundle");
+    LOGGER(ERROR) << "Failed to craete result bundle.";
     return false;
   }
   auto it = data.begin();
index b8a0d24..827ddd4 100644 (file)
@@ -137,8 +137,8 @@ std::shared_ptr<const wgt::parse::WidgetInfo>
 bool ApplicationData::LoadManifestData() {
   std::string config_xml_path(application_path_ + kConfigXml);
   if (!utils::Exists(config_xml_path)) {
-    LoggerE("Failed to load manifest data. : No such file '%s'",
-            config_xml_path.c_str());
+    LOGGER(ERROR) << "Failed to load manifest data. : No such file '"
+                  << config_xml_path << "'.";
     return false;
   }
 
@@ -182,8 +182,8 @@ bool ApplicationData::LoadManifestData() {
     for (auto iter = handlers.begin(); iter != handlers.end(); ++iter) {
       delete *iter;
     }
-    LoggerE("Failed to load manifest data. : %s",
-            manifest_parser.GetErrorMessage().c_str());
+    LOGGER(ERROR) << "Failed to load manifest data : "
+                  << manifest_parser.GetErrorMessage();
     return false;
   }
 
index 9d9f734..d336af2 100644 (file)
@@ -53,8 +53,8 @@ bool DBusClient::Connect(const std::string& address) {
       G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
       NULL, NULL, &err);
   if (!connection_) {
-    LoggerE("Failed to connect to bus address %s : %s",
-           address.c_str(), err->message);
+    LOGGER(ERROR) << "Failed to connect to bus address " << address
+                  << " : " << err->message;
     g_error_free(err);
     return false;
   }
@@ -82,7 +82,7 @@ GVariant* DBusClient::Call(const std::string& iface,
         connection_, NULL, "/", iface.c_str(), method.c_str(), parameters,
         reply_type, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
     if (!reply) {
-      LoggerE("Failed to CallSync : %s", err->message);
+      LOGGER(ERROR) << "Failed to CallSync : " << err->message;
       g_error_free(err);
     }
   } else {
index 581e75d..9dda4f4 100644 (file)
@@ -20,7 +20,7 @@ static void OnMethodCall(GDBusConnection* connection,
                          gpointer user_data) {
   DBusServer* self = reinterpret_cast<DBusServer*>(user_data);
   if (!self) {
-    LoggerE("DBusServer is NULL.");
+    LOGGER(ERROR) << "DBusServer is NULL.";
     return;
   }
   auto callback = self->GetMethodCallback(interface_name);
@@ -38,7 +38,7 @@ static GVariant* OnGetProperty(GDBusConnection* connection,
                                gpointer user_data) {
   DBusServer* self = reinterpret_cast<DBusServer*>(user_data);
   if (!self) {
-    LoggerE("DBusServer is NULL.");
+    LOGGER(ERROR) << "DBusServer is NULL.";
     return NULL;
   }
 
@@ -63,7 +63,7 @@ static gboolean OnSetProperty(GDBusConnection* connection,
                               gpointer user_data) {
   DBusServer* self = reinterpret_cast<DBusServer*>(user_data);
   if (!self) {
-    LoggerE("DBusServer is NULL.");
+    LOGGER(ERROR) << "DBusServer is NULL.";
     return FALSE;
   }
 
@@ -111,13 +111,13 @@ static gboolean OnClientRequest(GDBusServer* /*dbus_server*/,
         self->GetPeerCredentialsCallback();
     if (callback && !callback(
         g_dbus_connection_get_peer_credentials(connection))) {
-      LoggerW("Invalid peer credentials");
+      LOGGER(WARN) << "Invalid peer credentials.";
       g_dbus_connection_close_sync(connection, NULL, NULL);
     }
 
     GDBusNodeInfo* node_info = self->GetIntrospectionNodeInfo();
     if (!node_info) {
-      LoggerE("Introspection is not set.");
+      LOGGER(ERROR) << "Introspection is not set.";
       return TRUE;
     }
 
@@ -132,7 +132,7 @@ static gboolean OnClientRequest(GDBusServer* /*dbus_server*/,
                           NULL,
                           &err);
     if (reg_id == 0) {
-      LoggerE("Failed to register object : %s", err->message);
+      LOGGER(ERROR) << "Failed to register object : " << err->message;
       g_error_free(err);
     }
   }
@@ -182,7 +182,7 @@ void DBusServer::Start(const std::string& name) {
                   guid, NULL, NULL, &err);
   g_free(guid);
   if (!server_) {
-    LoggerE("Failed to create dbus server : %s", err->message);
+    LOGGER(ERROR) << "Failed to create dbus server : " << err->message;
     g_error_free(err);
     return;
   }
@@ -192,8 +192,6 @@ void DBusServer::Start(const std::string& name) {
                    G_CALLBACK(OnClientRequest), this);
 
   g_dbus_server_start(server_);
-
-  LoggerD("DBusServer(%s) has been started.", address.c_str());
 }
 
 std::string DBusServer::GetClientAddress() const {
@@ -204,8 +202,8 @@ void DBusServer::SetIntrospectionXML(const std::string& xml) {
   GError* err = NULL;
   node_info_ = g_dbus_node_info_new_for_xml(xml.c_str(), &err);
   if (!node_info_) {
-    LoggerE("Failed to create node info from introspection xml : %s",
-            err->message);
+    LOGGER(ERROR) << "Failed to create node info from introspection xml : "
+                  << err->message;
     g_error_free(err);
   }
 }
@@ -220,8 +218,8 @@ void DBusServer::SendSignal(GDBusConnection* connection,
       iface.c_str(), signal_name.c_str(),
       parameters, &err);
   if (!ret) {
-    LoggerE("Failed to emit signal : '%s.%s'",
-            iface.c_str(), signal_name.c_str());
+    LOGGER(ERROR) << "Failed to emit signal : '"
+                  << iface << '.' << signal_name << "'";
     g_error_free(err);
   }
 }
index 53e7e40..24a8407 100755 (executable)
@@ -57,13 +57,13 @@ void LocaleManager::UpdateSystemLocale() {
   std::string lang = localeToBCP47LangTag(str);
 
   if (lang.length() == 0) {
-    LoggerE("Language tag was invalid");
+    LOGGER(ERROR) << "Language tag was invalid";
     return;
   }
 
   system_locales_.clear();
   while (true) {
-    LoggerD("Processing language description: %s", lang.c_str());
+    LOGGER(DEBUG) << "Processing language description: " << lang;
     system_locales_.push_back(lang);
 
     // compatibility with lower language Tag by SDK
index babde2c..7d59ef2 100644 (file)
@@ -6,6 +6,7 @@
 #define WRT_COMMON_LOGGER_H_
 
 #include <dlog.h>
+#include <sstream>
 
 #undef LOGGER_TAG
 #define LOGGER_TAG "WRT"
 #define SLoggerW(fmt, args...) _LOGGER_SLOG(DLOG_WARN, fmt, ##args)
 #define SLoggerE(fmt, args...) _LOGGER_SLOG(DLOG_ERROR, fmt, ##args)
 
+namespace wrt {
+namespace utils {
+
+class LogMessageVodify {
+ public:
+  LogMessageVodify() {}
+  void operator&(const std::ostream&) const {}
+};
+
+class LogMessage {
+ public:
+  LogMessage(int severity, const char* file, const char* func, const int line)
+      : severity_(severity), file_(file), func_(func), line_(line) {}
+  ~LogMessage() {
+    __dlog_print(LOG_ID_MAIN, severity_, LOGGER_TAG,
+                 "%s: %s(%d) > %s", file_, func_, line_, stream_.str().c_str());
+  }
+  std::ostream& stream() { return stream_; }
+ private:
+  const int severity_;
+  const char* file_;
+  const char* func_;
+  const int line_;
+  std::ostringstream stream_;
+};
+
+}  // namespace utils
+}  // namespace wrt
+
+#define LOGGER(severity)                                                      \
+  wrt::utils::LogMessageVodify() &                                            \
+    wrt::utils::LogMessage(DLOG_ ## severity,                                 \
+                           __FILE__, __FUNCTION__, __LINE__).stream()
+
+
 #endif  // WRT_COMMON_LOGGER_H_
index d9a2d13..0f617ec 100644 (file)
@@ -10,8 +10,8 @@
 namespace wrt {
 
 void PrintProfileLog(const char* func, const char* tag) {
-  LoggerD("[PROF] [%s] %s:%s", utils::GetCurrentMilliSeconds().c_str(),
-                               func, tag);
+  LOGGER(DEBUG) << "[PROF] [" << utils::GetCurrentMilliSeconds() << "] "
+                << func << ":" << tag;
 }
 
 }  // namespace wrt
index 83e42b8..ad07474 100755 (executable)
@@ -73,7 +73,7 @@ static bool CompareStringWithWildcard(const std::string& origin,
     std::regex re(wildcard_str, std::regex_constants::icase);
     return std::regex_match(target.begin(), target.end(), re);
   } catch (std::regex_error& e) {
-    LoggerE("regex exception happened");
+    LOGGER(ERROR) << "regex_error caught: " << e.what();
     return false;
   }
 }
@@ -214,7 +214,7 @@ std::string ResourceManager::GetDefaultOrEmpty() {
       }
     }
   } else {
-    LoggerW("AppWidgetInfo is NULL.");
+    LOGGER(WARN) << "AppWidgetInfo is NULL.";
   }
 
   if (!default_src.empty()) {
@@ -248,7 +248,7 @@ std::unique_ptr<ResourceManager::Resource> ResourceManager::GetStartResource(
     const AppControl* app_control) {
   std::string operation = app_control->operation();
   if (operation.empty()) {
-    LoggerE("operation(mandatory) is NULL");
+    LOGGER(ERROR) << "operation(mandatory) is NULL";
     return std::unique_ptr<Resource>(new Resource(GetDefaultOrEmpty()));
   }
 
@@ -258,10 +258,10 @@ std::unique_ptr<ResourceManager::Resource> ResourceManager::GetStartResource(
     mime = GetMimeFromUri(uri);
   }
 
-  LoggerD("Passed AppControl data");
-  LoggerD(" - operation : %s", operation.c_str());
-  LoggerD(" - mimetype  : %s", mime.c_str());
-  LoggerD(" - uri       : %s", uri.c_str());
+  LOGGER(DEBUG) << "Passed AppControl data";
+  LOGGER(DEBUG) << " - operation : " << operation;
+  LOGGER(DEBUG) << " - mimetype  : " << mime;
+  LOGGER(DEBUG) << " - uri       : " << uri;
 
   if (application_data_ == NULL ||
       application_data_->app_control_info_list() == NULL) {
@@ -315,7 +315,7 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) {
     if (url.compare(0, check.length(), check) == 0) {
       url.erase(0, check.length());
     } else {
-      LoggerE("appid was invalid");
+      LOGGER(ERROR) << "Invalid appid";
       return result;
     }
   } else if (url.compare(file_scheme) == 0) {
@@ -328,7 +328,7 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) {
   }
 
   if (url.empty()) {
-    LoggerE("URL Localization error");
+    LOGGER(ERROR) << "URL Localization error";
     return result;
   }
 
index bbf92c9..591cb06 100644 (file)
@@ -41,17 +41,16 @@ bool Extension::Initialize() {
 
   void* handle = dlopen(library_path_.c_str(), RTLD_LAZY);
   if (!handle) {
-    LoggerE("Error loading extension '%s' : %s",
-            library_path_.c_str(), dlerror());
+    LOGGER(ERROR) << "Error loading extension '"
+                  << library_path_ << "' : " << dlerror();
     return false;
   }
 
   XW_Initialize_Func initialize = reinterpret_cast<XW_Initialize_Func>(
       dlsym(handle, "XW_Initialize"));
   if (!initialize) {
-    LoggerE(
-        "Error loading extension '%s' : couldn't get XW_Initialize function",
-        library_path_.c_str());
+    LOGGER(ERROR) << "Error loading extension '" << library_path_
+                  << "' : couldn't get XW_Initialize function.";
     dlclose(handle);
     return false;
   }
@@ -62,9 +61,8 @@ bool Extension::Initialize() {
 
   int ret = initialize(xw_extension_, ExtensionAdapter::GetInterface);
   if (ret != XW_OK) {
-    LoggerE(
-        "Error loading extension '%s' : XW_Initialize() returned error value.",
-        library_path_.c_str());
+    LOGGER(ERROR) << "Error loading extension '" << library_path_
+                  << "' : XW_Initialize() returned error value.";
     dlclose(handle);
     return false;
   }
index 36a9cd9..e13afc1 100644 (file)
@@ -34,7 +34,7 @@ XW_Instance ExtensionAdapter::GetNextXWInstance() {
 void ExtensionAdapter::RegisterExtension(Extension* extension) {
   XW_Extension xw_extension = extension->xw_extension_;
   if (!(xw_extension > 0 && xw_extension < next_xw_extension_)) {
-    LoggerW("xw_extension (%d) is invalid.", xw_extension);
+    LOGGER(WARN) << "xw_extension (" << xw_extension << ") is invalid.";
     return;
   }
   if (extension_map_.find(xw_extension) == extension_map_.end())
@@ -44,7 +44,7 @@ void ExtensionAdapter::RegisterExtension(Extension* extension) {
 void ExtensionAdapter::UnregisterExtension(Extension* extension) {
   XW_Extension xw_extension = extension->xw_extension_;
   if (!(xw_extension > 0 && xw_extension < next_xw_extension_)) {
-    LoggerW("xw_extension (%d) is invalid.", xw_extension);
+    LOGGER(WARN) << "xw_extension (" << xw_extension << ") is invalid.";
     return;
   }
   if (extension_map_.find(xw_extension) != extension_map_.end())
@@ -54,7 +54,7 @@ void ExtensionAdapter::UnregisterExtension(Extension* extension) {
 void ExtensionAdapter::RegisterInstance(ExtensionInstance* instance) {
   XW_Instance xw_instance = instance->xw_instance_;
   if (!(xw_instance > 0 && xw_instance < next_xw_instance_)) {
-    LoggerW("xw_instance (%d) is invalid.", xw_instance);
+    LOGGER(WARN) << "xw_instance (" << xw_instance << ") is invalid.";
     return;
   }
   if (instance_map_.find(xw_instance) == instance_map_.end())
@@ -64,7 +64,7 @@ void ExtensionAdapter::RegisterInstance(ExtensionInstance* instance) {
 void ExtensionAdapter::UnregisterInstance(ExtensionInstance* instance) {
   XW_Instance xw_instance = instance->xw_instance_;
   if (!(xw_instance > 0 && xw_instance < next_xw_instance_)) {
-    LoggerW("xw_instance (%d) is invalid.", xw_instance);
+    LOGGER(WARN) << "xw_instance (" << xw_instance << ") is invalid.";
     return;
   }
   if (instance_map_.find(xw_instance) != instance_map_.end())
@@ -123,7 +123,7 @@ const void* ExtensionAdapter::GetInterface(const char* name) {
     return &permissionsInterface1;
   }
 
-  LoggerW("Interface '%s' is not supported.", name);
+  LOGGER(WARN) << "Interface '" << name << "' is not supported.";
   return NULL;
 }
 
@@ -146,7 +146,7 @@ ExtensionInstance* ExtensionAdapter::GetExtensionInstance(
 
 #define CHECK(x, xw) \
   if (!x) { \
-    LoggerW("Ignoring call. Invalid %s = %d", #xw, xw); \
+    LOGGER(WARN) << "Ignoring call. Invalid " << #xw << " = " << xw; \
     return; \
   }
 
@@ -271,4 +271,7 @@ int ExtensionAdapter::PermissionsRegisterPermissions(XW_Extension xw_extension,
     return XW_ERROR;
 }
 
+#undef CHECK
+#undef RETURN_IF_INITIALIZED
+
 }  // namespace wrt
index 9d65e6c..c45536d 100644 (file)
@@ -69,7 +69,7 @@ bool ExtensionServer::Start(const StringVector& paths) {
   // Connect to DBusServer for Application of Runtime
   if (!dbus_application_client_.ConnectByName(
           app_uuid_ + "." + std::string(kDBusNameForApplication))) {
-    LoggerE("Failed to connect to the dbus server for Application.");
+    LOGGER(ERROR) << "Failed to connect to the dbus server for Application.";
     return false;
   }
 
@@ -127,16 +127,16 @@ bool ExtensionServer::RegisterSymbols(Extension* extension) {
   std::string name = extension->name();
 
   if (extension_symbols_.find(name) != extension_symbols_.end()) {
-    LoggerW("Ignoring extension with name already registred. '%s'",
-            name.c_str());
+    LOGGER(WARN) << "Ignoring extension with name already registred. '"
+                 << name << "'";
     return false;
   }
 
   Extension::StringVector entry_points = extension->entry_points();
   for (auto it = entry_points.begin(); it != entry_points.end(); ++it) {
     if (extension_symbols_.find(*it) != extension_symbols_.end()) {
-      LoggerW("Ignoring extension with entry_point already registred. '%s'",
-              (*it).c_str());
+      LOGGER(WARN) << "Ignoring extension with entry_point already registred. '"
+                   << (*it) << "'";
       return false;
     }
   }
@@ -157,7 +157,8 @@ void ExtensionServer::GetRuntimeVariable(const char* key, char* value,
       g_variant_new("(s)", key), G_VARIANT_TYPE("(s)"));
 
   if (!ret) {
-    LoggerE("Failed to get runtime variable from Application. (%s)", key);
+    LOGGER(ERROR) << "Failed to get runtime variable from Application. ("
+                  << key << ")";
     return;
   }
 
@@ -179,8 +180,6 @@ void ExtensionServer::HandleDBusMethod(GDBusConnection* connection,
                                        const std::string& method_name,
                                        GVariant* parameters,
                                        GDBusMethodInvocation* invocation) {
-  LoggerD("HandleDBusMethod (%s)", method_name.c_str());
-
   if (method_name == kMethodGetExtensions) {
     OnGetExtensions(invocation);
   } else if (method_name == kMethodCreateInstance) {
@@ -240,7 +239,7 @@ void ExtensionServer::OnCreateInstance(
   // find extension with given the extension name
   auto it = extensions_.find(extension_name);
   if (it == extensions_.end()) {
-    LoggerE("Failed to find extension [%s]", extension_name.c_str());
+    LOGGER(ERROR) << "Failed to find extension '" << extension_name << "'";
     g_dbus_method_invocation_return_error(
         invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
         "Not found extension %s", extension_name.c_str());
@@ -250,8 +249,8 @@ void ExtensionServer::OnCreateInstance(
   // create instance
   ExtensionInstance* instance = it->second->CreateInstance();
   if (!instance) {
-    LoggerE("Failed to create instance of extension [%s]",
-            extension_name.c_str());
+    LOGGER(ERROR) << "Failed to create instance of extension '"
+                  << extension_name << "'";
     g_dbus_method_invocation_return_error(
         invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
         "Failed to create instance of extension %s", extension_name.c_str());
@@ -276,7 +275,7 @@ void ExtensionServer::OnDestroyInstance(
   // find instance with the given instance id
   auto it = instances_.find(instance_id);
   if (it == instances_.end()) {
-    LoggerE("Failed to find instance [%s]", instance_id.c_str());
+    LOGGER(ERROR) << "Failed to find instance '" << instance_id << "'";
     g_dbus_method_invocation_return_error(
         invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
         "Not found instance %s", instance_id.c_str());
@@ -299,7 +298,7 @@ void ExtensionServer::OnSendSyncMessage(
   // find instance with the given instance id
   auto it = instances_.find(instance_id);
   if (it == instances_.end()) {
-    LoggerE("Failed to find instance [%s]", instance_id.c_str());
+    LOGGER(ERROR) << "Failed to find instance '" << instance_id << "'";
     g_dbus_method_invocation_return_error(
         invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
         "Not found instance %s", instance_id.c_str());
@@ -317,7 +316,7 @@ void ExtensionServer::OnPostMessage(
     const std::string& instance_id, const std::string& msg) {
   auto it = instances_.find(instance_id);
   if (it == instances_.end()) {
-    LoggerE("Failed to find instance [%s]", instance_id.c_str());
+    LOGGER(ERROR) << "Failed to find instance '" << instance_id << "'";
     return;
   }
 
@@ -335,7 +334,7 @@ void ExtensionServer::PostMessageToJSCallback(
     GDBusConnection* connection, const std::string& instance_id,
     const std::string& msg) {
   if (!connection || g_dbus_connection_is_closed(connection)) {
-    LoggerE("Client connection is closed already.");
+    LOGGER(ERROR) << "Client connection is closed already.";
     return;
   }
 
@@ -368,7 +367,7 @@ bool ExtensionServer::StartExtensionProcess() {
 
   // Receive AppID from arguments.
   if (cmd->arguments().size() < 1) {
-    LoggerE("uuid is required.");
+    LOGGER(ERROR) << "uuid is required.";
     return false;
   }
   std::string uuid = cmd->arguments()[0];
@@ -376,15 +375,15 @@ bool ExtensionServer::StartExtensionProcess() {
   // Start ExtensionServer
   ExtensionServer server(uuid);
   if (!server.Start()) {
-    LoggerE("Failed to start extension server.");
+    LOGGER(ERROR) << "Failed to start extension server.";
     return false;
   }
 
-  LoggerI("extension process has been started.");
+  LOGGER(INFO) << "extension process has been started.";
 
   g_main_loop_run(loop);
 
-  LoggerI("extension process is exiting.");
+  LOGGER(INFO) << "extension process is exiting.";
 
   g_main_loop_unref(loop);
 
index db6d6c3..83bf1aa 100644 (file)
@@ -17,14 +17,14 @@ int main(int argc, char* argv[]) {
   wrt::CommandLine* cmd = wrt::CommandLine::ForCurrentProcess();
   if (cmd->HasOptionName(wrt::kSwitchExtensionServer)) {
     // If cmd has the switch '--extension-server', run as extension server.
-    LoggerI("Extension server process has been created.");
+    LOGGER(INFO) << "Extension server process has been created.";
     if (!wrt::ExtensionServer::StartExtensionProcess()) {
-      LoggerE("Failed to start extension server.");
+      LOGGER(ERROR) << "Failed to start extension server.";
       exit(EXIT_FAILURE);
     }
   } else {
-    // Default dehavior, run as runtime.
-    LoggerI("Runtime process has been created.");
+    // Default behavior, run as runtime.
+    LOGGER(INFO) << "Runtime process has been created.";
     ewk_init();
     char* chromium_arg_options[] = {
       argv[0],
index 447732e..b2e1b00 100755 (executable)
@@ -136,13 +136,13 @@ void NativeWindow::Initialize() {
 
 void NativeWindow::DidDeleteRequested(void* /*data*/,
     Evas_Object* /*obj*/, void* /*event_info*/) {
-  LoggerD("didDeleteRequested");
+  LOGGER(DEBUG) << "didDeleteRequested";
   elm_exit();
 }
 
 void NativeWindow::DidProfileChanged(void* /*data*/,
     Evas_Object* /*obj*/, void* /*event_info*/) {
-  LoggerD("didProfileChanged");
+  LOGGER(DEBUG) << "didProfileChanged";
 }
 
 Evas_Object* NativeWindow::evas_object() const {
index 4f71821..70e3989 100755 (executable)
@@ -100,7 +100,7 @@ int Runtime::Exec(int argc, char* argv[]) {
   ops.create = [](void* data) -> bool {
     Runtime* runtime = reinterpret_cast<Runtime*>(data);
     if (!runtime) {
-      LoggerE("Runtime has not been created.");
+      LOGGER(ERROR) << "Runtime has not been created.";
       return false;
     }
     return runtime->OnCreate();
@@ -110,7 +110,7 @@ int Runtime::Exec(int argc, char* argv[]) {
   ops.terminate = [](void* data) -> void {
     Runtime* runtime = reinterpret_cast<Runtime*>(data);
     if (!runtime) {
-      LoggerE("Runtime has not been created.");
+      LOGGER(ERROR) << "Runtime has not been created.";
       return;
     }
     runtime->OnTerminate();
@@ -120,7 +120,7 @@ int Runtime::Exec(int argc, char* argv[]) {
   ops.pause = [](void* data) -> void {
     Runtime* runtime = reinterpret_cast<Runtime*>(data);
     if (!runtime) {
-      LoggerE("Runtime has not been created.");
+      LOGGER(ERROR) << "Runtime has not been created.";
       return;
     }
     runtime->OnPause();
@@ -130,7 +130,7 @@ int Runtime::Exec(int argc, char* argv[]) {
   ops.resume = [](void* data) -> void {
     Runtime* runtime = reinterpret_cast<Runtime*>(data);
     if (!runtime) {
-      LoggerE("Runtime has not been created.");
+      LOGGER(ERROR) << "Runtime has not been created.";
       return;
     }
     runtime->OnResume();
@@ -140,7 +140,7 @@ int Runtime::Exec(int argc, char* argv[]) {
   ops.app_control = [](app_control_h app_control, void* data) -> void {
     Runtime* runtime = reinterpret_cast<Runtime*>(data);
     if (!runtime) {
-      LoggerE("Runtime has not been created.");
+      LOGGER(ERROR) << "Runtime has not been created.";
       return;
     }
     runtime->OnAppControl(app_control);
index 4742f2a..9cbceec 100755 (executable)
@@ -42,7 +42,7 @@ bool VibrationImpl::Initialize() {
 
   int ret = haptic_open(HAPTIC_DEVICE_0, &handle_);
   if (ret != HAPTIC_ERROR_NONE) {
-    LoggerE("Fail to open haptic device");
+    LOGGER(ERROR) << "Fail to open haptic device";
     handle_ = 0;
     return false;
   }
index 9a7d524..d53e16c 100755 (executable)
@@ -103,7 +103,7 @@ bool FindPrivilege(wrt::ApplicationData* app_data,
 void ExecExtensionProcess(const std::string& uuid) {
   pid_t pid = -1;
   if ((pid = fork()) < 0) {
-    LoggerE("Failed to fork child process for extension process.");
+    LOGGER(ERROR) << "Failed to fork child process for extension process.";
   }
   if (pid == 0) {
     CommandLine* cmd = CommandLine::ForCurrentProcess();
@@ -289,7 +289,8 @@ void WebApplication::Launch(std::unique_ptr<wrt::AppControl> appcontrol) {
                      void*) -> void {
     int x, y, w, h;
     evas_object_geometry_get(obj, &x, &y, &w, &h);
-    LoggerD("resize ! (%d, %d, %d, %d)\n", x, y, w, h);
+    LOGGER(DEBUG) << "resize ! ("
+                  << x << ", " << y << ", " << w << ", " << h << ")";
   };
   evas_object_event_callback_add(view->evas_object(),
                                  EVAS_CALLBACK_RESIZE,
@@ -374,7 +375,7 @@ void WebApplication::Suspend() {
 
   if (app_data_->setting_info() != NULL &&
       app_data_->setting_info()->background_support_enabled()) {
-    LoggerD("gone background (backgroud support enabed)");
+    LOGGER(DEBUG) << "gone background (backgroud support enabed)";
     return;
   }
 
@@ -505,13 +506,13 @@ bool WebApplication::OnContextMenuDisabled(WebView* /*view*/) {
 }
 
 void WebApplication::OnLoadStart(WebView* /*view*/) {
-  LoggerD("LoadStart");
+  LOGGER(DEBUG) << "LoadStart";
 }
 void WebApplication::OnLoadFinished(WebView* /*view*/) {
-  LoggerD("LoadFinished");
+  LOGGER(DEBUG) << "LoadFinished";
 }
 void WebApplication::OnRendered(WebView* /*view*/) {
-  LoggerD("Rendered");
+  LOGGER(DEBUG) << "Rendered";
 }
 
 void WebApplication::LaunchInspector(wrt::AppControl* appcontrol) {
@@ -621,7 +622,7 @@ void WebApplication::HandleDBusMethod(GDBusConnection* /*connection*/,
   if (method_name == kMethodNotifyEPCreated) {
     // TODO(wy80.choi): send signal to injected bundle to make connection
     // between injected bundle and extension process
-    LoggerD("Call!!!! NotifyEPCreated!");
+    LOGGER(DEBUG) << "Call!!!! NotifyEPCreated!";
   } else if (method_name == kMethodGetRuntimeVariable) {
     gchar* key;
     std::string value;
index d996451..320b728 100755 (executable)
@@ -296,7 +296,7 @@ void WebViewImpl::InitQuotaExceededCallback() {
       return EINA_TRUE;
 
     auto result_handler = [view](bool result) {
-      LoggerD("database quota Permission Result : %d", result);
+      LOGGER(DEBUG) << "database quota Permission Result : " << result;
       ewk_view_exceeded_database_quota_reply(view, result);
     };
     std::stringstream url;
@@ -326,7 +326,7 @@ void WebViewImpl::InitQuotaExceededCallback() {
       return EINA_TRUE;
 
     auto result_handler = [view](bool result) {
-      LoggerD("indexed db quota Permission Result : %d", result);
+      LOGGER(DEBUG) << "indexed db quota Permission Result : " << result;
       ewk_view_exceeded_indexed_database_quota_reply(view, result);
     };
     std::stringstream url;
@@ -356,7 +356,7 @@ void WebViewImpl::InitQuotaExceededCallback() {
       return EINA_TRUE;
 
     auto result_handler = [view](bool result) {
-      LoggerD("local file quota Permission Result : %d", result);
+      LOGGER(DEBUG) << "local file quota Permission Result : " << result;
       ewk_view_exceeded_local_file_system_quota_reply(view, result);
     };
     std::stringstream url;
@@ -552,7 +552,7 @@ void WebViewImpl::InitNotificationPermissionCallback() {
   auto request_callback = [](Evas_Object*,
                              Ewk_Notification_Permission_Request* request,
                              void* user_data) {
-    LoggerD("Notification Permission Request");
+    LOGGER(DEBUG) << "Notification Permission Request";
     WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
     if (!self->listener_) {
       ewk_notification_permission_reply(request, EINA_FALSE);
@@ -561,7 +561,7 @@ void WebViewImpl::InitNotificationPermissionCallback() {
 
     ewk_notification_permission_request_suspend(request);
     auto result_handler = [request](bool result) {
-      LoggerD("Notification Permission Result : %d", result);
+      LOGGER(DEBUG) << "Notification Permission Result : %d" << result;
       ewk_notification_permission_reply(request, result);
     };
     const Ewk_Security_Origin* ewk_origin =
@@ -589,7 +589,7 @@ void WebViewImpl::InitGeolocationPermissionCallback() {
       Evas_Object*,
       Ewk_Geolocation_Permission_Request* request,
       void* user_data) {
-    LoggerD("Geolocation Permission Request");
+    LOGGER(DEBUG) << "Geolocation Permission Request";
     WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
     if (self == NULL || self->listener_ == NULL) {
       ewk_geolocation_permission_reply(request, EINA_FALSE);
@@ -600,7 +600,7 @@ void WebViewImpl::InitGeolocationPermissionCallback() {
     const Ewk_Security_Origin* ewk_origin =
         ewk_geolocation_permission_request_origin_get(request);
     auto result_handler = [request](bool result) {
-      LoggerD("Geolocation Permission Result : %d", result);
+      LOGGER(DEBUG) << "Geolocation Permission Result : " << result;
       ewk_geolocation_permission_reply(request, result);
     };
 
@@ -626,7 +626,7 @@ void WebViewImpl::InitAuthenticationCallback() {
   auto auth_callback = [](void* user_data,
                           Evas_Object*,
                           void* event_info) {
-    LoggerD("Authentication Request");
+    LOGGER(DEBUG) << "Authentication Request";
     WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
     Ewk_Auth_Challenge* auth_challenge =
         static_cast<Ewk_Auth_Challenge*>(event_info);
@@ -638,7 +638,7 @@ void WebViewImpl::InitAuthenticationCallback() {
     auto result_handler = [auth_challenge](bool submit,
                                     const std::string& id,
                                     const std::string& password) {
-      LoggerD("Authentication Result : submit %d", submit);
+      LOGGER(DEBUG) << "Authentication Result : submit = " << submit;
       if (!submit) {
         ewk_auth_challenge_credential_cancel(auth_challenge);
         return;