From d686916fe254588cc4c3549031ea1f688f56b318 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 11 Oct 2016 16:55:57 -0700 Subject: [PATCH] Expose process.log when running as node --- atom/app/node_main.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index 040b4b615721..be75404ffa5a 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -4,20 +4,28 @@ #include "atom/app/node_main.h" +#include + #include "atom/app/uv_task_runner.h" #include "atom/browser/javascript_environment.h" #include "atom/browser/node_debugger.h" +#include "atom/common/native_mate_converters/string16_converter.h" #include "base/command_line.h" #include "base/feature_list.h" #include "base/threading/thread_task_runner_handle.h" #include "gin/array_buffer.h" #include "gin/public/isolate_holder.h" #include "gin/v8_initializer.h" +#include "native_mate/dictionary.h" #include "atom/common/node_includes.h" namespace atom { +void Log(const base::string16& message) { + std::cout << message << std::flush; +} + int NodeMain(int argc, char *argv[]) { base::CommandLine::Init(argc, argv); @@ -53,6 +61,9 @@ int NodeMain(int argc, char *argv[]) { node::LoadEnvironment(env); + mate::Dictionary dict(gin_env.isolate(), env->process_object()); + dict.SetMethod("log", &Log); + bool more; do { more = uv_run(env->event_loop(), UV_RUN_ONCE);