Skip to content

Commit

Permalink
logging: log when the filter is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Jul 18, 2022
1 parent dc88bc2 commit abf0a54
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions crates/sui-node/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ use tracing::info;
const LOGGING_ROUTE: &str = "/logging";

pub fn start_admin_server(port: u16, filter_handle: FilterHandle) {
let filter = filter_handle.get().unwrap();

let app = Router::new()
.route(LOGGING_ROUTE, get(get_filter))
.route(LOGGING_ROUTE, post(set_filter))
.layer(Extension(filter_handle));

let socket_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port);
info!("starting admin server on {}", socket_address);
info!(
filter =% filter,
address =% socket_address,
"starting admin server"
);

tokio::spawn(async move {
axum::Server::bind(&socket_address)
Expand All @@ -41,8 +47,11 @@ async fn set_filter(
Extension(filter_handle): Extension<FilterHandle>,
new_filter: String,
) -> (StatusCode, String) {
match filter_handle.update(new_filter) {
Ok(()) => (StatusCode::OK, "".into()),
match filter_handle.update(&new_filter) {
Ok(()) => {
info!(filter =% new_filter, "Log filter updated");
(StatusCode::OK, "".into())
}
Err(err) => (StatusCode::BAD_REQUEST, err.to_string()),
}
}

0 comments on commit abf0a54

Please sign in to comment.