Skip to content

Commit d361fcf

Browse files
committed
feat: print connect/disconnect message into device logs
1 parent ecc2961 commit d361fcf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/handler.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ pub async fn handle_client(
1111
esp_connect_info: &EspConnectInfo,
1212
state: SharedAppState,
1313
) -> Result<()> {
14+
tracing::info!(
15+
file = format!("device_{}", esp_connect_info.id),
16+
"============= Client connected! ============="
17+
);
18+
1419
{
1520
let state_inner = state.inner.read().await;
1621
if state_inner.should_update {
1722
if let Some(firmware) = super::updater::should_update(&state, esp_connect_info).await? {
23+
tracing::info!(
24+
file = format!("device_{}", esp_connect_info.id),
25+
"Starting update."
26+
);
1827
super::updater::update_client(&mut socket, &esp_connect_info, firmware).await?;
1928

2029
return Ok(());
@@ -35,6 +44,7 @@ pub async fn handle_client(
3544
_ = hb_interval.tick() => {
3645
if !hb_received {
3746
error!("Closing connection due to no heartbeat ({})", esp_connect_info.id);
47+
tracing::error!(file = format!("device_{}", esp_connect_info.id), "============= Closing connection (due to no heartbeat) =============");
3848
break;
3949
}
4050

src/http.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,8 @@ async fn handle_socket(socket: WebSocket, esp_connect_info: EspConnectInfo, stat
6666
}
6767

6868
info!("Client disconnected: {esp_connect_info:?}");
69+
tracing::info!(
70+
file = format!("device_{}", esp_connect_info.id),
71+
"============= Client disconnected! ============="
72+
);
6973
}

0 commit comments

Comments
 (0)