Skip to content

Commit 7dd46f8

Browse files
committed
refactor: replace error logging with warn for non-critical issues
1 parent 35447b6 commit 7dd46f8

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

examples/proxy.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use tokio::sync::Mutex;
4343
use tokio_util::sync::CancellationToken;
4444
use tower::ServiceBuilder;
4545
use tower_http::cors::CorsLayer;
46-
use tracing::{error, info, warn};
46+
use tracing::{info, warn};
4747

4848
/// A SIP proxy server that supports UDP, TCP and WebSocket clients
4949
#[derive(Parser, Debug)]
@@ -207,7 +207,7 @@ async fn main() -> Result<()> {
207207
}
208208
#[cfg(not(feature = "websocket"))]
209209
{
210-
error!("WebSocket feature not enabled");
210+
warn!("WebSocket feature not enabled");
211211
}
212212
}
213213

@@ -538,7 +538,7 @@ async fn handle_bye(state: AppState, mut tx: Transaction) -> Result<()> {
538538
tx.respond(resp).await?;
539539
}
540540
_ => {
541-
error!("UAC/BYE Received request: {}", msg.to_string());
541+
warn!("UAC/BYE Received request: {}", msg.to_string());
542542
}
543543
}
544544
}
@@ -639,7 +639,7 @@ async fn handle_websocket(client_addr: ClientAddr, socket: WebSocket, _state: Ap
639639
{
640640
Ok(conn) => conn,
641641
Err(e) => {
642-
error!("Failed to create channel connection: {:?}", e);
642+
warn!("Failed to create channel connection: {:?}", e);
643643
return;
644644
}
645645
};
@@ -671,7 +671,7 @@ async fn handle_websocket(client_addr: ClientAddr, socket: WebSocket, _state: Ap
671671
) {
672672
Ok(msg) => msg,
673673
Err(e) => {
674-
error!("Error updating SIP via: {:?}", e);
674+
warn!("Error updating SIP via: {:?}", e);
675675
continue;
676676
}
677677
};
@@ -680,7 +680,7 @@ async fn handle_websocket(client_addr: ClientAddr, socket: WebSocket, _state: Ap
680680
sip_connection.clone(),
681681
local_addr.clone(),
682682
)) {
683-
error!("Error forwarding message to transport: {:?}", e);
683+
warn!("Error forwarding message to transport: {:?}", e);
684684
break;
685685
}
686686
}
@@ -699,7 +699,7 @@ async fn handle_websocket(client_addr: ClientAddr, socket: WebSocket, _state: Ap
699699
sip_connection.clone(),
700700
local_addr.clone(),
701701
)) {
702-
error!("Error forwarding binary message to transport: {:?}", e);
702+
warn!("Error forwarding binary message to transport: {:?}", e);
703703
break;
704704
}
705705
}
@@ -714,15 +714,15 @@ async fn handle_websocket(client_addr: ClientAddr, socket: WebSocket, _state: Ap
714714
Some(Ok(Message::Ping(data))) => {
715715
let mut sink = ws_sink.lock().await;
716716
if let Err(e) = sink.send(Message::Pong(data)).await {
717-
error!("Error sending pong response: {}", e);
717+
warn!("Error sending pong response: {}", e);
718718
break;
719719
}
720720
}
721721
Some(Ok(Message::Pong(_))) => {
722722
// Just acknowledge the pong
723723
}
724724
Some(Err(e)) => {
725-
error!("WebSocket error: {}", e);
725+
warn!("WebSocket error: {}", e);
726726
break;
727727
}
728728
None => {
@@ -743,7 +743,7 @@ async fn handle_websocket(client_addr: ClientAddr, socket: WebSocket, _state: Ap
743743
);
744744
let mut sink = ws_sink.lock().await;
745745
if let Err(e) = sink.send(Message::Text(message_text.into())).await {
746-
error!("Error sending message to WebSocket: {}", e);
746+
warn!("Error sending message to WebSocket: {}", e);
747747
break;
748748
}
749749
}

src/transport/stream.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tokio::{
1212
sync::Mutex,
1313
};
1414
use tokio_util::codec::{Decoder, Encoder};
15-
use tracing::{debug, error, info};
15+
use tracing::{debug, info, warn};
1616

1717
pub(super) const MAX_SIP_MESSAGE_SIZE: usize = 65535;
1818

@@ -141,7 +141,7 @@ where
141141
let mut read_half = match self.read_half.lock().await.take() {
142142
Some(read_half) => read_half,
143143
None => {
144-
error!("Connection closed");
144+
warn!("Connection closed");
145145
return Ok(());
146146
}
147147
};
@@ -179,7 +179,7 @@ where
179179
connection.clone(),
180180
remote_addr.clone(),
181181
)) {
182-
error!("Error sending incoming message: {:?}", e);
182+
warn!("Error sending incoming message: {:?}", e);
183183
return Err(e.into());
184184
}
185185
}
@@ -193,14 +193,14 @@ where
193193
break;
194194
}
195195
Err(e) => {
196-
error!("Error decoding message from {}: {:?}", remote_addr, e);
196+
warn!("Error decoding message from {}: {:?}", remote_addr, e);
197197
// Continue processing despite decode errors
198198
}
199199
}
200200
}
201201
}
202202
Err(e) => {
203-
error!("Error reading from stream: {}", e);
203+
warn!("Error reading from stream: {}", e);
204204
break;
205205
}
206206
}

src/transport/tcp_listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::Result;
66
use std::fmt;
77
use std::{net::SocketAddr, sync::Arc};
88
use tokio::net::TcpListener;
9-
use tracing::{error, info, warn};
9+
use tracing::{info, warn};
1010
pub struct TcpListenerConnectionInner {
1111
pub local_addr: SipAddr,
1212
pub external: Option<SipAddr>,
@@ -56,7 +56,7 @@ impl TcpListenerConnection {
5656
) {
5757
Ok(tcp_connection) => tcp_connection,
5858
Err(e) => {
59-
error!("Failed to create TCP connection: {:?}", e);
59+
warn!("Failed to create TCP connection: {:?}", e);
6060
continue;
6161
}
6262
};

src/transport/tls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tokio_rustls::{
1414
TlsAcceptor, TlsConnector,
1515
};
1616
use tokio_util::sync::CancellationToken;
17-
use tracing::{error, info, warn};
17+
use tracing::{info, warn};
1818

1919
// TLS configuration
2020
#[derive(Clone, Debug)]
@@ -99,7 +99,7 @@ impl TlsListenerConnection {
9999
let tls_stream = match acceptor_clone.accept(stream).await {
100100
Ok(stream) => stream,
101101
Err(e) => {
102-
error!("TLS handshake failed: {}", e);
102+
warn!("TLS handshake failed: {}", e);
103103
return;
104104
}
105105
};
@@ -119,7 +119,7 @@ impl TlsListenerConnection {
119119
{
120120
Ok(conn) => conn,
121121
Err(e) => {
122-
error!("Failed to create TLS connection: {:?}", e);
122+
warn!("Failed to create TLS connection: {:?}", e);
123123
return;
124124
}
125125
};

src/transport/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
use std::{net::SocketAddr, sync::Arc};
1010
use tokio::net::UdpSocket;
1111
use tokio_util::sync::CancellationToken;
12-
use tracing::{debug, error, info};
12+
use tracing::{debug, info, warn};
1313
pub struct UdpInner {
1414
pub conn: UdpSocket,
1515
pub addr: SipAddr,
@@ -68,7 +68,7 @@ impl UdpConnection {
6868
let (len, addr) = match self.inner.conn.recv_from(&mut buf).await {
6969
Ok((len, addr)) => (len, addr),
7070
Err(e) => {
71-
error!("error receiving UDP packet: {}", e);
71+
warn!("error receiving UDP packet: {}", e);
7272
continue;
7373
}
7474
};

src/transport/websocket.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use tokio_tungstenite::{
2222
MaybeTlsStream, WebSocketStream,
2323
};
2424
use tokio_util::sync::CancellationToken;
25-
use tracing::{debug, error, info, warn};
25+
use tracing::{debug, info, warn};
2626

2727
// Define a type alias for the WebSocket sink to make the code more readable
2828
type WsSink = futures_util::stream::SplitSink<
@@ -123,7 +123,7 @@ impl WebSocketListenerConnection {
123123
{
124124
Ok(ws) => ws,
125125
Err(e) => {
126-
error!("Error upgrading to WebSocket: {}", e);
126+
warn!("Error upgrading to WebSocket: {}", e);
127127
return;
128128
}
129129
};
@@ -260,7 +260,7 @@ impl StreamConnection for WebSocketConnection {
260260
let mut ws_read = match self.inner.ws_read.lock().await.take() {
261261
Some(ws_read) => ws_read,
262262
None => {
263-
error!("WebSocket connection closed");
263+
warn!("WebSocket connection closed");
264264
return Ok(());
265265
}
266266
};
@@ -281,7 +281,7 @@ impl StreamConnection for WebSocketConnection {
281281
sip_connection.clone(),
282282
remote_addr.clone(),
283283
)) {
284-
error!("Error sending incoming message: {:?}", e);
284+
warn!("Error sending incoming message: {:?}", e);
285285
break;
286286
}
287287
}
@@ -292,7 +292,7 @@ impl StreamConnection for WebSocketConnection {
292292
Ok(Message::Binary(bin)) => {
293293
if bin == *KEEPALIVE_REQUEST {
294294
if let Err(e) = self.send_raw(KEEPALIVE_RESPONSE).await {
295-
error!("Error sending keepalive response: {:?}", e);
295+
warn!("Error sending keepalive response: {:?}", e);
296296
}
297297
continue;
298298
}
@@ -303,7 +303,7 @@ impl StreamConnection for WebSocketConnection {
303303
sip_connection.clone(),
304304
remote_addr.clone(),
305305
)) {
306-
error!("Error sending incoming message: {:?}", e);
306+
warn!("Error sending incoming message: {:?}", e);
307307
break;
308308
}
309309
}
@@ -315,7 +315,7 @@ impl StreamConnection for WebSocketConnection {
315315
Ok(Message::Ping(data)) => {
316316
let mut sink = self.inner.ws_sink.lock().await;
317317
if let Err(e) = sink.send(Message::Pong(data)).await {
318-
error!("Error sending pong: {}", e);
318+
warn!("Error sending pong: {}", e);
319319
break;
320320
}
321321
}
@@ -324,7 +324,7 @@ impl StreamConnection for WebSocketConnection {
324324
break;
325325
}
326326
Err(e) => {
327-
error!("WebSocket error: {}", e);
327+
warn!("WebSocket error: {}", e);
328328
break;
329329
}
330330
_ => {}

0 commit comments

Comments
 (0)