Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --enable-logging not hard coded #391

Merged
merged 1 commit into from May 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/browser/process.rs
Expand Up @@ -87,6 +87,12 @@ pub struct LaunchOptions<'a> {
#[builder(default = "true")]
pub sandbox: bool,

/// Determines whether to run the browser with logging enabled
/// (this can cause unwanted new shell window in Windows 10 and above).
/// Check <https://github.com/rust-headless-chrome/rust-headless-chrome/issues/371>
#[builder(default = "false")]
pub enable_logging: bool,

/// Launch the browser with a specific window width and height.
#[builder(default = "None")]
pub window_size: Option<(u32, u32)>,
Expand Down Expand Up @@ -159,6 +165,7 @@ impl<'a> Default for LaunchOptions<'a> {
LaunchOptions {
headless: true,
sandbox: true,
enable_logging: false,
idle_browser_timeout: Duration::from_secs(30),
window_size: None,
path: None,
Expand Down Expand Up @@ -310,7 +317,6 @@ impl Process {
let mut args = vec![
port_option.as_str(),
"--disable-gpu",
"--enable-logging",
"--verbose",
"--log-level=0",
"--no-first-run",
Expand Down Expand Up @@ -343,6 +349,10 @@ impl Process {
args.extend(["--ignore-certificate-errors"]);
}

if launch_options.enable_logging {
args.extend(["--enable-logging"]);
}

let proxy_server_option = if let Some(proxy_server) = launch_options.proxy_server {
format!("--proxy-server={proxy_server}")
} else {
Expand Down