Reuse Log method

This commit is contained in:
Kevin Sawicki 2016-10-12 09:33:28 -07:00
parent d686916fe2
commit 0740b2f66b
3 changed files with 11 additions and 13 deletions

View file

@ -4,11 +4,10 @@
#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/api/atom_bindings.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "base/command_line.h"
#include "base/feature_list.h"
@ -22,10 +21,6 @@
namespace atom {
void Log(const base::string16& message) {
std::cout << message << std::flush;
}
int NodeMain(int argc, char *argv[]) {
base::CommandLine::Init(argc, argv);
@ -59,10 +54,10 @@ int NodeMain(int argc, char *argv[]) {
if (node_debugger.IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext());
node::LoadEnvironment(env);
mate::Dictionary process(gin_env.isolate(), env->process_object());
process.SetMethod("log", &AtomBindings::Log);
mate::Dictionary dict(gin_env.isolate(), env->process_object());
dict.SetMethod("log", &Log);
node::LoadEnvironment(env);
bool more;
do {

View file

@ -79,10 +79,6 @@ void FatalErrorCallback(const char* location, const char* message) {
Crash();
}
void Log(const base::string16& message) {
std::cout << message << std::flush;
}
} // namespace
@ -157,4 +153,9 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) {
self->pending_next_ticks_.clear();
}
// static
void AtomBindings::Log(const base::string16& message) {
std::cout << message << std::flush;
}
} // namespace atom

View file

@ -27,6 +27,8 @@ class AtomBindings {
// load native code from Electron instead.
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
static void Log(const base::string16& message);
private:
void ActivateUVLoop(v8::Isolate* isolate);