From 172c64414682ebcf47dc92a6015e3376dba5fc65 Mon Sep 17 00:00:00 2001 From: Cong Liu Date: Mon, 28 Mar 2016 15:57:37 +0800 Subject: [PATCH] Respect logging CLI arguments On Windows, logging module is initialized after sandbox creation. But NW package is initialized ealier that that, which causes the creation of `debug.log` no matter if `--enable-logging` or `--disable-logging` is set. The patch moved the initialization of NW package after logging is initialized. The limitation is that logging CLI argument can't be passed by `chromium-args` in nw package, because nw package is initialized after the logging initialization. Fixed nwjs/nw.js#4637 --- chrome/app/chrome_main_delegate.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index 9742c32aaf428..311339c29830d 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -740,8 +740,11 @@ void ChromeMainDelegate::PreSandboxStartup() { crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); #endif +#if defined(OS_MACOSX) if (process_type.empty()) nw::InitNWPackage(); +#endif + #if defined(OS_MACOSX) // On the Mac, the child executable lives at a predefined location within // the app bundle's versioned directory. @@ -909,6 +912,14 @@ void ChromeMainDelegate::SandboxInitialized(const std::string& process_type) { chrome_pdf::PPP_ShutdownModule); #endif #endif + +#if !define(OS_MACOSX) + // Make sure nw package is initialized after logging initialization. + // On Windows, the logging is initialized after sanbox is created. + // See https://github.com/nwjs/nw.js/issues/4637 + if (process_type.empty()) + nw::InitNWPackage(); +#endif } int ChromeMainDelegate::RunProcess(