feat: bring --enable-logging functionality in line with Chromium (#25089)
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
This commit is contained in:
parent
c841247815
commit
8ccab4ce91
18 changed files with 553 additions and 54 deletions
|
@ -100,6 +100,7 @@
|
|||
#include "shell/common/api/api.mojom.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/electron_paths.h"
|
||||
#include "shell/common/logging.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/common/platform_util.h"
|
||||
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
|
||||
|
@ -542,6 +543,15 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
|
|||
}
|
||||
#endif
|
||||
|
||||
// The zygote process is booted before JS runs, so DIR_USER_DATA isn't usable
|
||||
// at that time. It doesn't need --user-data-dir to be correct anyway, since
|
||||
// the zygote itself doesn't access anything in that directory.
|
||||
if (process_type != ::switches::kZygoteProcess) {
|
||||
base::FilePath user_data_dir;
|
||||
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
|
||||
command_line->AppendSwitchPath(::switches::kUserDataDir, user_data_dir);
|
||||
}
|
||||
|
||||
if (process_type == ::switches::kUtilityProcess ||
|
||||
process_type == ::switches::kRendererProcess) {
|
||||
// Copy following switches to child process.
|
||||
|
@ -794,6 +804,11 @@ bool ElectronBrowserClient::ArePersistentMediaDeviceIDsAllowed(
|
|||
return true;
|
||||
}
|
||||
|
||||
base::FilePath ElectronBrowserClient::GetLoggingFileName(
|
||||
const base::CommandLine& cmd_line) {
|
||||
return logging::GetLogFileName(cmd_line);
|
||||
}
|
||||
|
||||
void ElectronBrowserClient::SiteInstanceDeleting(
|
||||
content::SiteInstance* site_instance) {
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
|
|
|
@ -263,6 +263,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
|
|||
const GURL& scope,
|
||||
const GURL& site_for_cookies,
|
||||
const absl::optional<url::Origin>& top_frame_origin) override;
|
||||
base::FilePath GetLoggingFileName(const base::CommandLine& cmd_line) override;
|
||||
|
||||
// content::RenderProcessHostObserver:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/barrier_closure.h"
|
||||
#include "base/base_paths.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/no_destructor.h"
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/electron_paths.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
#include "shell/common/logging.h"
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
@ -269,6 +270,11 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
|||
// Initialize field trials.
|
||||
InitializeFieldTrials();
|
||||
|
||||
// Reinitialize logging now that the app has had a chance to set the app name
|
||||
// and/or user data directory.
|
||||
logging::InitElectronLogging(*base::CommandLine::ForCurrentProcess(),
|
||||
/* is_preinit = */ false);
|
||||
|
||||
// Initialize after user script environment creation.
|
||||
fake_browser_process_->PostEarlyInitialization();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue