win: Use util.format to format arguments in console.log.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 12 Feb 2014 12:17:14 +0000 (20:17 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 12 Feb 2014 12:32:30 +0000 (20:32 +0800)
browser/lib/init.coffee
common/api/atom_bindings.cc

index 1b22b3d259b38968b2ccd388f4d48a41248c9da4..42e8df0d20171ef282b6e2f71742f78f3b8ded60 100644 (file)
@@ -1,5 +1,6 @@
 fs   = require 'fs'
 path = require 'path'
+util = require 'util'
 
 # Expose information of current process.
 process.__atom_type = 'browser'
@@ -28,8 +29,10 @@ setImmediate ->
   if process.platform is 'win32'
     # Redirect node's console to use our own implementations, since node can not
     # handle console output when running as GUI program.
-    console.log = console.error = console.warn = process.log
-    process.stdout.write = process.stderr.write = process.log
+    print = (args...) ->
+      process.log util.format(args...)
+    console.log = console.error = console.warn = print
+    process.stdout.write = process.stderr.write = print
 
     # Always returns EOF for stdin stream.
     Readable = require('stream').Readable
index faa139a6c6109c29fe0f72b99ba24b1247677469..060486b457563c12f1e1b7c55c734725e5370c82 100644 (file)
@@ -158,11 +158,8 @@ void AtomBindings::ActivateUVLoop(
 
 // static
 void AtomBindings::Log(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  std::string message;
-  for (int i = 0; i < args.Length(); ++i)
-    message += *v8::String::Utf8Value(args[i]);
-
-  logging::LogMessage("CONSOLE", 0, 0).stream() << message;
+  v8::String::Utf8Value str(args[0]);
+  logging::LogMessage("CONSOLE", 0, 0).stream() << *str;
 }
 
 // static