Expose process.log when running as node

This commit is contained in:
Kevin Sawicki 2016-10-11 16:55:57 -07:00
parent fefc7c23f9
commit d686916fe2

View file

@ -4,20 +4,28 @@
#include "atom/app/node_main.h"
#include <iostream>
#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);