Skip to content

Commit

Permalink
Merge pull request #391 from HollowMan6/logging
Browse files Browse the repository at this point in the history
Make `--enable-logging` not hard coded
  • Loading branch information
mdrokz committed May 27, 2023
2 parents fa40745 + f7f9bd3 commit f127f42
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/browser/process.rs
Original file line number Diff line number Diff line change
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

0 comments on commit f127f42

Please sign in to comment.