]> khamidou — GitHub mirrors - electron.git/commitdiff
Fix console.* calls on Windows
authorEran Tiktin <eran.t@mce-sys.com>
Sat, 10 Oct 2015 03:39:02 +0000 (06:39 +0300)
committerEran Tiktin <eran.t@mce-sys.com>
Sat, 10 Oct 2015 03:39:02 +0000 (06:39 +0300)
- Calls for console.* on browser process are printed with no need for
--enable-logging
- The output is without the logging prefix
- The cursor in the terminal is always after the last output
- The first output starts on a new line and not at the prompt
- console.* from renderer are not printed to cmd
- Added a missing '\n' in the default_app help output

atom/app/atom_main_delegate.cc
atom/browser/default_app/main.js
atom/browser/lib/init.coffee
atom/common/api/atom_bindings.cc

index fe3c0e09ae33f68581a675c08510b068cb9ebd60..6ba1b89837c6b427f8657b76a4dbadb3d8d018ad 100644 (file)
@@ -5,6 +5,7 @@
 #include "atom/app/atom_main_delegate.h"
 
 #include <string>
+#include <iostream>
 
 #include "atom/app/atom_content_client.h"
 #include "atom/browser/atom_browser_client.h"
@@ -29,6 +30,9 @@ AtomMainDelegate::~AtomMainDelegate() {
 bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
   logging::LoggingSettings settings;
 #if defined(OS_WIN)
+  // On Windows the terminal returns immediately, so we add a new line to
+  // prevent output in the same line as the prompt.
+  std::wcout << std::endl;
 #if defined(DEBUG)
   // Print logging to debug.log on Windows
   settings.logging_dest = logging::LOG_TO_ALL;
index e2c29f2d7e691af0f939adfc5aa4cacbf8fe4acc..9cb468182d4dc901ab3a7d9326e458863b4fca04 100644 (file)
@@ -263,7 +263,7 @@ if (option.file && !option.webdriver) {
   helpMessage    += "A path to an Electron application may be specified. The path must be to \n";
   helpMessage    += "an index.js file or to a folder containing a package.json or index.js file.\n\n";
   helpMessage    += "Options:\n";
-  helpMessage    += "  -r, --require         Module to preload (option can be repeated)";
+  helpMessage    += "  -r, --require         Module to preload (option can be repeated)\n";
   helpMessage    += "  -h, --help            Print this usage message.\n";
   helpMessage    += "  -v, --version         Print the version.";
   console.log(helpMessage);
index b394c0fecc28e66352a5ef07c8bb98d669aab3b3..2b6b1bb3c239cb426b3c44f806176e479a0fd8aa 100644 (file)
@@ -22,7 +22,7 @@ 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.
   print = (args...) ->
-    process.log util.format(args...)
+    process.log util.format(args...) + "\n"
   console.log = console.error = console.warn = print
   process.stdout.write = process.stderr.write = print
 
index d6fb355e09d8d1cb075656acc0d663a9338ce820..1a44d1af0a0b2ade248f6f11210a45163ff9c213 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <algorithm>
 #include <string>
+#include <iostream>
 
 #include "atom/common/atom_version.h"
 #include "atom/common/chrome_version.h"
@@ -40,7 +41,7 @@ void FatalErrorCallback(const char* location, const char* message) {
 }
 
 void Log(const base::string16& message) {
-  logging::LogMessage("CONSOLE", 0, 0).stream() << message;
+  std::wcout << message;
 }
 
 }  // namespace