feat: polish logging if the server is unavailable
This commit is contained in:
parent
1229127101
commit
1bce912a1a
3 changed files with 8 additions and 8 deletions
|
|
@ -12,11 +12,7 @@ use tracing::Instrument;
|
|||
|
||||
use crate::{
|
||||
mc_server::{sanitize_addr, MinecraftAPI, MinecraftServerHandle, ServerDeploymentStatus},
|
||||
packets::{
|
||||
clientbound::status::StatusTrait,
|
||||
serverbound::handshake::{self},
|
||||
SendPacket,
|
||||
},
|
||||
packets::{clientbound::status::StatusTrait, SendPacket},
|
||||
OpaqueError,
|
||||
};
|
||||
|
||||
|
|
@ -438,6 +434,7 @@ impl fmt::Debug for ServerDeploymentStatus {
|
|||
Self::Starting => write!(f, "Starting"),
|
||||
Self::PodOk => write!(f, "PodOk"),
|
||||
Self::Offline => write!(f, "Offline"),
|
||||
Self::Unavailable(s) => write!(f, "Unavailable ({s})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,9 +235,9 @@ async fn handle_status<T: MinecraftServerHandle>(
|
|||
.instrument(span.clone())
|
||||
.await
|
||||
.map_err(|_| tracing::debug!("failed to send pong packet"));
|
||||
let _guard = span.enter();
|
||||
|
||||
tracing::info!(status = "unavailable", "status request");
|
||||
let status = ServerDeploymentStatus::Unavailable(e.get_kind().to_string());
|
||||
tracing::info!(status = ?status, "status request");
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
|
@ -264,6 +264,7 @@ async fn handle_status<T: MinecraftServerHandle>(
|
|||
status_struct.description.text =
|
||||
format!("{motd}\n§4Offline§r §oJoin to start!§r - {BYE_MESSAGE}");
|
||||
}
|
||||
ServerDeploymentStatus::Unavailable(_) => unreachable!(),
|
||||
};
|
||||
|
||||
mc_server::complete_status_request(client_stream, status_struct).await?;
|
||||
|
|
@ -321,7 +322,7 @@ async fn handle_login<T: MinecraftServerHandle>(
|
|||
|
||||
match traffic.error {
|
||||
Some(e) => {
|
||||
tracing::info!(
|
||||
tracing::warn!(
|
||||
tx = traffic.tx,
|
||||
rx = traffic.rx,
|
||||
err = ?e,
|
||||
|
|
@ -344,6 +345,7 @@ async fn handle_login<T: MinecraftServerHandle>(
|
|||
.await?;
|
||||
mc_server::send_disconnect(client_stream, format!("[\"\",{{\"text\":\"Okayy, §2starting§r the server!\n\n\"}},{{\"text\":\"{BYE_MESSAGE}\"}}]").as_str()).await?;
|
||||
}
|
||||
ServerDeploymentStatus::Unavailable(_) => unreachable!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ pub enum ServerDeploymentStatus {
|
|||
Starting,
|
||||
PodOk,
|
||||
Offline,
|
||||
Unavailable(String),
|
||||
}
|
||||
|
||||
pub fn sanitize_addr(addr: &str) -> &str {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue