win: Don't output newline except for main process

This commit is contained in:
Cheng Zhao 2015-10-15 12:44:55 +08:00
parent 7a6ef0ec6e
commit f52c4af605

View file

@ -21,6 +21,15 @@
namespace atom { namespace atom {
namespace {
bool IsBrowserProcess(base::CommandLine* cmd) {
std::string process_type = cmd->GetSwitchValueASCII(switches::kProcessType);
return process_type.empty();
}
} // namespace
AtomMainDelegate::AtomMainDelegate() { AtomMainDelegate::AtomMainDelegate() {
} }
@ -28,10 +37,13 @@ AtomMainDelegate::~AtomMainDelegate() {
} }
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
auto command_line = base::CommandLine::ForCurrentProcess();
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 // On Windows the terminal returns immediately, so we add a new line to
// prevent output in the same line as the prompt. // prevent output in the same line as the prompt.
if (IsBrowserProcess(command_line))
std::wcout << std::endl; std::wcout << std::endl;
#if defined(DEBUG) #if defined(DEBUG)
// Print logging to debug.log on Windows // Print logging to debug.log on Windows
@ -47,7 +59,6 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
#endif // !defined(OS_WIN) #endif // !defined(OS_WIN)
// Only enable logging when --enable-logging is specified. // Only enable logging when --enable-logging is specified.
auto command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kEnableLogging)) { if (!command_line->HasSwitch(switches::kEnableLogging)) {
settings.logging_dest = logging::LOG_NONE; settings.logging_dest = logging::LOG_NONE;
logging::SetMinLogLevel(logging::LOG_NUM_SEVERITIES); logging::SetMinLogLevel(logging::LOG_NUM_SEVERITIES);
@ -83,7 +94,7 @@ void AtomMainDelegate::PreSandboxStartup() {
} }
// Only append arguments for browser process. // Only append arguments for browser process.
if (!process_type.empty()) if (!IsBrowserProcess(command_line))
return; return;
#if defined(OS_WIN) #if defined(OS_WIN)