Merge pull request #7578 from electron/windows-logging

Show console output from Windows when ELECTRON_RUN_AS_NODE is set
This commit is contained in:
Cheng Zhao 2016-10-17 20:22:39 +08:00 committed by GitHub
commit ce847fc3ca
6 changed files with 47 additions and 5 deletions

View file

@ -14,6 +14,12 @@
#include "gin/public/isolate_holder.h"
#include "gin/v8_initializer.h"
#if defined(OS_WIN)
#include "atom/common/api/atom_bindings.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "native_mate/dictionary.h"
#endif
#include "atom/common/node_includes.h"
namespace atom {
@ -51,6 +57,11 @@ int NodeMain(int argc, char *argv[]) {
if (node_debugger.IsRunning())
env->AssignToContext(v8::Debug::GetDebugContext());
#if defined(OS_WIN)
mate::Dictionary process(gin_env.isolate(), env->process_object());
process.SetMethod("log", &AtomBindings::Log);
#endif
node::LoadEnvironment(env);
bool more;

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);