Skip to content

Commit

Permalink
send logging level change requests to workers
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Oct 18, 2023
1 parent 35415c1 commit 641daa3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 16 additions & 2 deletions bin/src/command/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ impl CommandServer {
Err(_) => Err(anyhow::Error::msg("wrong i32 for metrics configuration")),
}
}
Some(RequestType::Logging(logging_filter)) => self.set_logging_level(logging_filter),
Some(RequestType::Logging(logging_filter)) => {
self.set_logging_level(logging_filter, client_id).await
}
Some(RequestType::SubscribeEvents(_)) => {
self.event_subscribers.insert(client_id.clone());
Ok(Some(Success::SubscribeEvent(client_id.clone())))
Expand Down Expand Up @@ -1187,7 +1189,11 @@ impl CommandServer {
Ok(None)
}

pub fn set_logging_level(&mut self, logging_filter: String) -> anyhow::Result<Option<Success>> {
pub async fn set_logging_level(
&mut self,
logging_filter: String,
client_id: String,
) -> anyhow::Result<Option<Success>> {
debug!("Changing main process log level to {}", logging_filter);
logging::LOGGER.with(|l| {
let directives = logging::parse_logging_spec(&logging_filter);
Expand All @@ -1197,6 +1203,14 @@ impl CommandServer {
// will have the new logging filter value
::std::env::set_var("RUST_LOG", &logging_filter);
debug!("Logging level now: {}", ::std::env::var("RUST_LOG")?);

// notify the workers too
let _worker_success = self
.worker_requests(
client_id,
RequestType::Logging(logging_filter.clone()).into(),
)
.await?;
Ok(Some(Success::Logging(logging_filter)))
}

Expand Down
1 change: 0 additions & 1 deletion lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,6 @@ impl Server {
}
_other_request => {}
}

self.notify_proxys(message);
}

Expand Down

0 comments on commit 641daa3

Please sign in to comment.