Merge pull request #3056 from etiktin/fix_console_windows
Fix console.* calls on Windows
This commit is contained in:
commit
be5f1b09f4
4 changed files with 16 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include "atom/app/atom_main_delegate.h"
|
#include "atom/app/atom_main_delegate.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "atom/app/atom_content_client.h"
|
#include "atom/app/atom_content_client.h"
|
||||||
#include "atom/browser/atom_browser_client.h"
|
#include "atom/browser/atom_browser_client.h"
|
||||||
|
@ -29,6 +30,9 @@ AtomMainDelegate::~AtomMainDelegate() {
|
||||||
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||||
logging::LoggingSettings settings;
|
logging::LoggingSettings settings;
|
||||||
#if defined(OS_WIN)
|
#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)
|
#if defined(DEBUG)
|
||||||
// Print logging to debug.log on Windows
|
// Print logging to debug.log on Windows
|
||||||
settings.logging_dest = logging::LOG_TO_ALL;
|
settings.logging_dest = logging::LOG_TO_ALL;
|
||||||
|
|
|
@ -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 += "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 += "an index.js file or to a folder containing a package.json or index.js file.\n\n";
|
||||||
helpMessage += "Options:\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 += " -h, --help Print this usage message.\n";
|
||||||
helpMessage += " -v, --version Print the version.";
|
helpMessage += " -v, --version Print the version.";
|
||||||
console.log(helpMessage);
|
console.log(helpMessage);
|
||||||
|
|
|
@ -21,10 +21,15 @@ globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||||
if process.platform is 'win32'
|
if process.platform is 'win32'
|
||||||
# Redirect node's console to use our own implementations, since node can not
|
# Redirect node's console to use our own implementations, since node can not
|
||||||
# handle console output when running as GUI program.
|
# handle console output when running as GUI program.
|
||||||
print = (args...) ->
|
consoleLog = (args...) ->
|
||||||
process.log util.format(args...)
|
process.log util.format(args...) + "\n"
|
||||||
console.log = console.error = console.warn = print
|
streamWrite = (chunk, encoding, callback) ->
|
||||||
process.stdout.write = process.stderr.write = print
|
chunk = chunk.toString(encoding) if Buffer.isBuffer chunk
|
||||||
|
process.log chunk
|
||||||
|
callback() if callback
|
||||||
|
true
|
||||||
|
console.log = console.error = console.warn = consoleLog
|
||||||
|
process.stdout.write = process.stderr.write = streamWrite
|
||||||
|
|
||||||
# Always returns EOF for stdin stream.
|
# Always returns EOF for stdin stream.
|
||||||
Readable = require('stream').Readable
|
Readable = require('stream').Readable
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "atom/common/atom_version.h"
|
#include "atom/common/atom_version.h"
|
||||||
#include "atom/common/chrome_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) {
|
void Log(const base::string16& message) {
|
||||||
logging::LogMessage("CONSOLE", 0, 0).stream() << message;
|
std::wcout << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue