diff --git a/deps/node/lib/internal/bootstrap/switches/is_main_thread.js b/deps/node/lib/internal/bootstrap/switches/is_main_thread.js index e68ddd3bd5..b64b362e15 100644 --- a/deps/node/lib/internal/bootstrap/switches/is_main_thread.js +++ b/deps/node/lib/internal/bootstrap/switches/is_main_thread.js @@ -41,19 +41,27 @@ const { guessHandleType } = internalBinding('util'); function createWritableStdioStream(fd) { let stream; // Note stream._type is used for test-module-load-list.js + + // @lwnode + if (process.lwnode) { + // The handle type guessed of stdout(1) or stderr(2) can be PIPE on tizen. + if (process.lwnode.hasSystemInfo('tizen') && (fd === 1 || fd === 2)) { + const { Writable } = require('stream'); + stream = new Writable({ + write(chunk, encoding, callback) { + process.lwnode._print(chunk.toString()); + callback(); + } + }); + // For supporting legacy API we put the FD here. + stream.fd = fd; + stream._isStdio = true; + return stream; + } + } + switch (guessHandleType(fd)) { case 'TTY': - // @lwnode - if (process.lwnode) { - const { Writable } = require('stream'); - stream = new Writable({ - write(chunk, encoding, callback) { - process.lwnode._print(chunk.toString()); - callback(); - } - }); - break; - } const tty = require('tty'); stream = new tty.WriteStream(fd); stream._type = 'tty'; diff --git a/deps/node/src/lwnode/aul-event-receiver.cc b/deps/node/src/lwnode/aul-event-receiver.cc index f556c41be3..89b76ab68a 100644 --- a/deps/node/src/lwnode/aul-event-receiver.cc +++ b/deps/node/src/lwnode/aul-event-receiver.cc @@ -75,16 +75,17 @@ bool AULEventReceiver::start(int argc, char* argv[]) { if (hasAulArguments(argc, argv)) { isEventReceiverRunning_ = true; - initLoggerOutput(); - - aul_launch_init(aulEventHandler, nullptr); - aul_launch_argv_handler(argc, argv); char appid[kMaxPackageNameSize + 1]; aul_app_get_appid_bypid(getpid(), appid, kMaxPackageNameSize); appid_ = appid; - LWNODE_DEV_LOG("appid: ", appid_); + initLoggerOutput(appid_); + + LWNODE_DEV_LOG("appid:", appid_); + + aul_launch_init(aulEventHandler, nullptr); + aul_launch_argv_handler(argc, argv); char* path = app_get_resource_path(); if (uv_chdir(path) != 0) { @@ -110,9 +111,9 @@ bool AULEventReceiver::isEventReceiverRunning() { return isEventReceiverRunning_; } -void AULEventReceiver::initLoggerOutput() { - if (!appid_.empty()) { - LogKind::user()->tag = appid_; +void AULEventReceiver::initLoggerOutput(const std::string tag) { + if (!tag.empty()) { + LogKind::user()->tag = tag; } LogOption::setDefaultOutputInstantiator([&]() { diff --git a/deps/node/src/lwnode/aul-event-receiver.h b/deps/node/src/lwnode/aul-event-receiver.h index ac20891ccb..39337e368e 100644 --- a/deps/node/src/lwnode/aul-event-receiver.h +++ b/deps/node/src/lwnode/aul-event-receiver.h @@ -37,7 +37,7 @@ class AULEventReceiver { } #endif - void initLoggerOutput(); + void initLoggerOutput(const std::string tag = ""); bool isEventReceiverRunning(); private: diff --git a/src/api/utils/logger/logger.cc b/src/api/utils/logger/logger.cc index ab6d6686be..880fce1a7f 100644 --- a/src/api/utils/logger/logger.cc +++ b/src/api/utils/logger/logger.cc @@ -26,6 +26,9 @@ void DlogOut::flush(std::stringstream& ss, std::shared_ptr config) { auto c = config ? std::static_pointer_cast(config) : LogKind::lwnode(); + + // TODO: handle the case where users manually select a logging method. + #ifdef HOST_TIZEN dlog_print(DLOG_INFO, c->tag.c_str(), "%s", ss.str().c_str()); #else