From: jaekuk lee Date: Wed, 14 Mar 2018 07:41:07 +0000 (+0000) Subject: Revert "Revert "Print console messages to dlog"" X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f43e4ca0423d4b540953f5df6286014c2f73d2ba;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Revert "Revert "Print console messages to dlog"" This reverts commit 1e66211336d2c6b42b525a3ddbffdddafac77ac5. Change-Id: I5255a6b28e70da7d84bf8716d4c468b7daac6b18 --- diff --git a/atom/browser/api/atom_api_pwrt.cc b/atom/browser/api/atom_api_pwrt.cc index e249288..e8a75a6 100644 --- a/atom/browser/api/atom_api_pwrt.cc +++ b/atom/browser/api/atom_api_pwrt.cc @@ -7,6 +7,7 @@ #include "atom/common/node_includes.h" #include "tizen/common/application_data.h" #include "tizen/common/command_line.h" +#include namespace atom { @@ -48,6 +49,11 @@ bool PWRT::isTizenWebApp() { } } +void PWRT::Log(const std::string& message) { + std::string output = "[JS LOG] " + message; + dlog_print(DLOG_INFO, "WRT", output.c_str()); +} + // static mate::Handle PWRT::Create(v8::Isolate* isolate) { LOG(INFO) << "PWRT::Create"; @@ -63,7 +69,8 @@ void PWRT::BuildPrototype( mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("getMessage", &PWRT::GetMessage) .SetMethod("getPath", &PWRT::GetPath) - .SetMethod("isTizenWebApp", &PWRT::isTizenWebApp); + .SetMethod("isTizenWebApp", &PWRT::isTizenWebApp) + .SetMethod("log", &PWRT::Log); } } // namespace api diff --git a/atom/browser/api/atom_api_pwrt.h b/atom/browser/api/atom_api_pwrt.h index ac466d7..647a5ae 100644 --- a/atom/browser/api/atom_api_pwrt.h +++ b/atom/browser/api/atom_api_pwrt.h @@ -19,6 +19,7 @@ class PWRT : public mate::TrackableObject { std::string GetMessage(); std::string GetPath(); bool isTizenWebApp(); + void Log(const std::string& message); protected: explicit PWRT(v8::Isolate* isolate); diff --git a/lib/browser/init.js b/lib/browser/init.js index b9fe447..308dde7 100644 --- a/lib/browser/init.js +++ b/lib/browser/init.js @@ -42,6 +42,11 @@ if (process.platform === 'win32') { process.stdout.write = process.stderr.write = streamWrite } +let {pwrt} = require('electron'); +console.log = console.error = console.warn = function(...args) { + pwrt.log(util.format(...args)); +}; + // Don't quit on fatal error. process.on('uncaughtException', function (error) { // Do nothing if the user has a custom uncaught exception handler.