fix(tui): stop raw prints from corrupting the TUI
Log lines were painting over the alternate-screen TUI because some messages bypassed the buffered logger and wrote straight to the terminal: - a live println! in GetPeerAddressHandler fired on every peer-address lookup (i.e. constantly while browsing/downloading) — routed to the buffered debug! logger. - the TUI's error handlers used eprintln! in the render loop and in background search/download worker threads — routed to the buffered warn! logger so failures no longer smear the screen. The logger already defers to a buffer while the TUI holds the screen; the fix is simply to go through it instead of print!/eprintln!.
This commit is contained in:
@@ -22,7 +22,7 @@ impl MessageHandler<ServerMessage> for GetPeerAddressHandler {
|
|||||||
let port = message.read_int32();
|
let port = message.read_int32();
|
||||||
let obfuscation_type = message.read_int32();
|
let obfuscation_type = message.read_int32();
|
||||||
let obfuscated_port = message.read_int32() as u16;
|
let obfuscated_port = message.read_int32() as u16;
|
||||||
println!("GetPeerAddressHandler: {username:?}"); // Debug print
|
crate::debug!("GetPeerAddressHandler: {username:?}");
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send(ServerMessage::GetPeerAddressResponse {
|
.send(ServerMessage::GetPeerAddressResponse {
|
||||||
|
|||||||
@@ -501,7 +501,9 @@ pub fn show_multi_download_progress(
|
|||||||
let _ = tx.send((download, receiver));
|
let _ = tx.send((download, receiver));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to start download for {filename}: {e}");
|
soulseek_rs::warn!(
|
||||||
|
"Failed to start download for {filename}: {e}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -771,7 +771,9 @@ impl MainTui {
|
|||||||
let _ = sender.send((download, rx));
|
let _ = sender.send((download, rx));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to queue download {path}: {e}");
|
soulseek_rs::warn!(
|
||||||
|
"Failed to queue download {path}: {e}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -954,7 +956,7 @@ impl MainTui {
|
|||||||
if let Some(name) = self.state.rooms.selected_room_name() {
|
if let Some(name) = self.state.rooms.selected_room_name() {
|
||||||
let newly_opened = self.state.rooms.focus_or_open(&name);
|
let newly_opened = self.state.rooms.focus_or_open(&name);
|
||||||
if newly_opened && let Err(e) = self.client.join_room(&name) {
|
if newly_opened && let Err(e) = self.client.join_room(&name) {
|
||||||
eprintln!("Failed to join {name}: {e}");
|
soulseek_rs::warn!("Failed to join {name}: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -964,7 +966,7 @@ impl MainTui {
|
|||||||
if let Some(name) = self.state.rooms.close_active()
|
if let Some(name) = self.state.rooms.close_active()
|
||||||
&& let Err(e) = self.client.leave_room(&name)
|
&& let Err(e) = self.client.leave_room(&name)
|
||||||
{
|
{
|
||||||
eprintln!("Failed to leave {name}: {e}");
|
soulseek_rs::warn!("Failed to leave {name}: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -982,7 +984,7 @@ impl MainTui {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Err(e) = self.client.say_in_room(&room, &text) {
|
if let Err(e) = self.client.say_in_room(&room, &text) {
|
||||||
eprintln!("Failed to say in {room}: {e}");
|
soulseek_rs::warn!("Failed to say in {room}: {e}");
|
||||||
}
|
}
|
||||||
if let Some(room) = self.state.rooms.open.get_mut(active) {
|
if let Some(room) = self.state.rooms.open.get_mut(active) {
|
||||||
room.input.clear();
|
room.input.clear();
|
||||||
@@ -1331,7 +1333,7 @@ impl MainTui {
|
|||||||
Ok((download, rx)) => {
|
Ok((download, rx)) => {
|
||||||
let _ = sender.send((download, rx));
|
let _ = sender.send((download, rx));
|
||||||
}
|
}
|
||||||
Err(e) => eprintln!("Failed to retry {filename}: {e}"),
|
Err(e) => soulseek_rs::warn!("Failed to retry {filename}: {e}"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1636,7 +1638,7 @@ impl MainTui {
|
|||||||
peer: recipient.to_string(),
|
peer: recipient.to_string(),
|
||||||
text: text.to_string(),
|
text: text.to_string(),
|
||||||
}),
|
}),
|
||||||
Err(e) => eprintln!("Failed to send message: {e}"),
|
Err(e) => soulseek_rs::warn!("Failed to send message: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1681,7 +1683,7 @@ impl MainTui {
|
|||||||
// Results will be polled in update_search_results
|
// Results will be polled in update_search_results
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Search failed: {e}");
|
soulseek_rs::warn!("Search failed: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1794,9 +1796,10 @@ impl MainTui {
|
|||||||
let _ = sender.send((download, rx));
|
let _ = sender.send((download, rx));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!(
|
soulseek_rs::warn!(
|
||||||
"Failed to start download for {}: {}",
|
"Failed to start download for {}: {}",
|
||||||
file.filename, e
|
file.filename,
|
||||||
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user