Improve the console messages to include pkgid
authorJongHeon Choi <j-h.choi@samsung.com>
Wed, 6 Jul 2016 02:14:01 +0000 (11:14 +0900)
committerJongHeon Choi <j-h.choi@samsung.com>
Wed, 6 Jul 2016 06:08:43 +0000 (15:08 +0900)
runtime/browser/web_application.cc
runtime/browser/web_view_impl.cc

index 5a19350..cbd4c45 100644 (file)
@@ -127,6 +127,7 @@ const char* kDBPrivateSection = "private";
 
 const char* kDefaultCSPRule =
     "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
+const char* kResWgtPath = "res/wgt/";
 
 bool FindPrivilege(common::ApplicationData* app_data,
                    const std::string& privilege) {
@@ -705,6 +706,12 @@ void WebApplication::OnConsoleMessage(const std::string& msg, int level) {
   static bool enabled = (getenv(kConsoleLogEnableKey) != NULL);
   enabled = true;
 
+  std::string split_msg = msg;
+  std::size_t pos = msg.find(kResWgtPath);
+  if (pos != std::string::npos) {
+    split_msg = msg.substr(pos + strlen(kResWgtPath));
+  }
+
   if (debug_mode_ || verbose_mode_ || enabled) {
     int dlog_level = DLOG_DEBUG;
     switch (level) {
@@ -718,7 +725,8 @@ void WebApplication::OnConsoleMessage(const std::string& msg, int level) {
         dlog_level = DLOG_DEBUG;
         break;
     }
-    LOGGER_RAW(dlog_level, kConsoleMessageLogTag) << msg;
+    LOGGER_RAW(dlog_level, kConsoleMessageLogTag)
+      << "[" << app_data_->pkg_id() << "] " << split_msg;
   }
 }
 
index 6523327..14c527e 100644 (file)
@@ -525,7 +525,7 @@ void WebViewImpl::InitConsoleMessageCallback() {
 
     std::stringstream buf;
     if (line_number) {
-        buf << common::utils::BaseName(ewk_console_message_source_get(msg))
+        buf << ewk_console_message_source_get(msg)
             << ":" << line_number << ": ";
     }
     buf << ewk_console_message_text_get(msg);