From: WonYoung Choi Date: Thu, 18 Jun 2015 10:55:58 +0000 (+0900) Subject: Simplify ConsoleMessage X-Git-Tag: accepted/tizen/mobile/20151006.042140~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e5e0987bfb1446bd893eec09f07074b59325593;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Simplify ConsoleMessage Change-Id: I5d4cea4901d1b69b65b0b9ccb93b68fc8a55ca1e --- diff --git a/src/common/logger.h b/src/common/logger.h index 2bb5ee5..1ea5864 100755 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -50,15 +50,24 @@ class LogMessageVodify { class LogMessage { public: - LogMessage(int severity, const char* file, const char* func, const int line) - : severity_(severity), file_(file), func_(func), line_(line) {} + LogMessage(int severity, const char* tag, + const char* file, const char* func, const int line) + : severity_(severity), tag_(tag), file_(file), func_(func), line_(line) {} + LogMessage(int severity, const char* tag) + : severity_(severity), tag_(tag), file_(NULL), func_(NULL), line_(0) {} ~LogMessage() { - __dlog_print(LOG_ID_MAIN, severity_, LOGGER_TAG, - "%s: %s(%d) > %s", file_, func_, line_, stream_.str().c_str()); + if (file_) { + __dlog_print(LOG_ID_MAIN, severity_, tag_, + "%s: %s(%d) > %s", + file_, func_, line_, stream_.str().c_str()); + } else { + __dlog_print(LOG_ID_MAIN, severity_, tag_, "%s", stream_.str().c_str()); + } } std::ostream& stream() { return stream_; } private: const int severity_; + const char* tag_; const char* file_; const char* func_; const int line_; @@ -75,8 +84,12 @@ class LogMessage { #define LOGGER(severity) \ wrt::utils::LogMessageVodify() & \ - wrt::utils::LogMessage(DLOG_ ## severity, \ + wrt::utils::LogMessage(DLOG_ ## severity, LOGGER_TAG, \ __MODULE__, __FUNCTION__, __LINE__).stream() +#define LOGGER_RAW(level, tag) \ + wrt::utils::LogMessageVodify() & \ + wrt::utils::LogMessage(level, tag).stream() + #endif // WRT_COMMON_LOGGER_H_ diff --git a/src/runtime/web_application.cc b/src/runtime/web_application.cc index ef1f1e4..1612379 100755 --- a/src/runtime/web_application.cc +++ b/src/runtime/web_application.cc @@ -630,6 +630,7 @@ void WebApplication::OnLanguageChanged() { void WebApplication::OnConsoleMessage(const std::string& msg, int level) { static bool enabled = (getenv(kConsoleLogEnableKey) != NULL); enabled = true; + if (debug_mode_ || enabled) { int dlog_level = DLOG_DEBUG; switch (level) { @@ -643,7 +644,7 @@ void WebApplication::OnConsoleMessage(const std::string& msg, int level) { dlog_level = DLOG_DEBUG; break; } - LOG_(LOG_ID_MAIN, dlog_level, kConsoleMessageLogTag, "%s", msg.c_str()); + LOGGER_RAW(dlog_level, kConsoleMessageLogTag) << msg; } } diff --git a/src/runtime/web_view_impl.cc b/src/runtime/web_view_impl.cc index 3ae2068..583b37b 100755 --- a/src/runtime/web_view_impl.cc +++ b/src/runtime/web_view_impl.cc @@ -23,6 +23,7 @@ #include "runtime/native_window.h" #include "common/logger.h" +#include "common/file_utils.h" namespace wrt { @@ -453,8 +454,8 @@ void WebViewImpl::InitConsoleMessageCallback() { std::stringstream buf; if (line_number) { - buf << ewk_console_message_source_get(msg) << ":"; - buf << line_number << ":"; + buf << utils::BaseName(ewk_console_message_source_get(msg)) << ":"; + buf << line_number << ": "; } buf << ewk_console_message_text_get(msg); int level = ewk_console_message_level_get(msg);