diff --git a/app/buck2_client_ctx/src/daemon/client/mod.rs b/app/buck2_client_ctx/src/daemon/client/mod.rs index 76be780cb8c4..e98959e892cb 100644 --- a/app/buck2_client_ctx/src/daemon/client/mod.rs +++ b/app/buck2_client_ctx/src/daemon/client/mod.rs @@ -429,10 +429,10 @@ impl BuckdClient { )) } - pub async fn set_log_filter(&mut self, log_filter: String) -> anyhow::Result<()> { + pub async fn set_log_filter(&mut self, req: SetLogFilterRequest) -> anyhow::Result<()> { self.client .daemon_only_mut() - .set_log_filter(Request::new(SetLogFilterRequest { log_filter })) + .set_log_filter(Request::new(req)) .await?; Ok(()) @@ -614,7 +614,7 @@ impl<'a> FlushingBuckdClient<'a> { wrap_method!(kill(reason: &str), ()); wrap_method!(status(snapshot: bool), StatusResponse); wrap_method!(check_version(), VersionCheckResult); - wrap_method!(set_log_filter(log_filter: String), ()); + wrap_method!(set_log_filter(log_filter: SetLogFilterRequest), ()); } /// Create a stream that is sent over as a parameter via GRPC to the daemon. diff --git a/buck2_client/src/commands/debug/set_log_filter.rs b/buck2_client/src/commands/debug/set_log_filter.rs index 6f61b44849f2..825e2c066fe4 100644 --- a/buck2_client/src/commands/debug/set_log_filter.rs +++ b/buck2_client/src/commands/debug/set_log_filter.rs @@ -10,12 +10,22 @@ use buck2_client_ctx::client_ctx::ClientCommandContext; use buck2_client_ctx::daemon::client::connect::BuckdConnectOptions; use buck2_client_ctx::exit_result::ExitResult; +use cli_proto::SetLogFilterRequest; #[derive(Debug, clap::Parser)] #[clap()] pub struct SetLogFilterCommand { + /// The log filter to apply. #[clap()] log_filter: String, + + /// Whether not to apply it to the daemon. + #[clap(long)] + no_daemon: bool, + + /// Whether not to apply it to the forkserver. + #[clap(long)] + no_forkserver: bool, } impl SetLogFilterCommand { @@ -27,7 +37,11 @@ impl SetLogFilterCommand { buckd .with_flushing() - .set_log_filter(self.log_filter) + .set_log_filter(SetLogFilterRequest { + log_filter: self.log_filter, + daemon: !self.no_daemon, + forkserver: !self.no_forkserver, + }) .await?; ExitResult::success() diff --git a/buck2_server/src/daemon/server.rs b/buck2_server/src/daemon/server.rs index d219469a1bb9..0b5ad2d7e09e 100644 --- a/buck2_server/src/daemon/server.rs +++ b/buck2_server/src/daemon/server.rs @@ -1113,19 +1113,23 @@ impl DaemonApi for BuckdServer { ) -> Result, Status> { let req = req.into_inner(); - self.0 - .log_reload_handle - .update_log_filter(&req.log_filter) - .context("Error updating daemon log filter") - .map_err(|e| Status::invalid_argument(format!("{:#}", e)))?; - - if let Ok(data) = self.0.daemon_state.data() { - if let Some(forkserver) = data.forkserver.as_ref() { - forkserver - .set_log_filter(req.log_filter) - .await - .context("Error forwarding daemon log filter to forkserver") - .map_err(|e| Status::invalid_argument(format!("{:#}", e)))?; + if req.daemon { + self.0 + .log_reload_handle + .update_log_filter(&req.log_filter) + .context("Error updating daemon log filter") + .map_err(|e| Status::invalid_argument(format!("{:#}", e)))?; + } + + if req.forkserver { + if let Ok(data) = self.0.daemon_state.data() { + if let Some(forkserver) = data.forkserver.as_ref() { + forkserver + .set_log_filter(req.log_filter) + .await + .context("Error forwarding daemon log filter to forkserver") + .map_err(|e| Status::invalid_argument(format!("{:#}", e)))?; + } } } diff --git a/cli_proto/daemon.proto b/cli_proto/daemon.proto index e7903dcd2df9..b93928881ec3 100644 --- a/cli_proto/daemon.proto +++ b/cli_proto/daemon.proto @@ -615,6 +615,8 @@ message FlushDepFilesRequest {} message SetLogFilterRequest { string log_filter = 1; + bool daemon = 2; + bool forkserver = 3; } message SetLogFilterResponse {}