Skip to content

Commit

Permalink
remove log::
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Mar 16, 2024
1 parent 6ef9330 commit a36415a
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 33 deletions.
7 changes: 4 additions & 3 deletions rtc-datachannel/src/data_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::message::{message_channel_ack::*, message_channel_open::*, *};
use bytes::{Buf, BytesMut};
use log::{debug, error};
use sctp::{PayloadProtocolIdentifier, ReliabilityType};
use shared::error::{Error, Result};
use shared::marshal::*;
Expand Down Expand Up @@ -143,7 +144,7 @@ impl DataChannel {
match self.handle_dcep(&mut data_buf) {
Ok(()) => {}
Err(err) => {
log::error!("Failed to handle DCEP: {:?}", err);
error!("Failed to handle DCEP: {:?}", err);
return Err(err);
}
}
Expand Down Expand Up @@ -207,11 +208,11 @@ impl DataChannel {
Message::DataChannelOpen(_) => {
// Note: DATA_CHANNEL_OPEN message is handled inside Server() method.
// Therefore, the message will not reach here.
log::debug!("Received DATA_CHANNEL_OPEN");
debug!("Received DATA_CHANNEL_OPEN");
self.write_data_channel_ack()?;
}
Message::DataChannelAck(_) => {
log::debug!("Received DATA_CHANNEL_ACK");
debug!("Received DATA_CHANNEL_ACK");
//self.commit_reliability_params();
}
};
Expand Down
3 changes: 2 additions & 1 deletion rtc-dtls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::extension::extension_use_srtp::SrtpProtectionProfile;
use crate::signature_hash_algorithm::{
parse_signature_schemes, SignatureHashAlgorithm, SignatureScheme,
};
use log::warn;
use shared::error::*;
use std::collections::HashMap;
use std::fmt;
Expand Down Expand Up @@ -314,7 +315,7 @@ impl ConfigBuilder {
if let Some(remote_addr) = remote_addr {
server_name = remote_addr.ip().to_string();
} else {
log::warn!("conn.remote_addr is empty, please set explicitly server_name in Config! Use default \"localhost\" as server_name now");
warn!("conn.remote_addr is empty, please set explicitly server_name in Config! Use default \"localhost\" as server_name now");
server_name = "localhost".to_owned();
}
}
Expand Down
3 changes: 2 additions & 1 deletion rtc-dtls/src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::sync::Arc;

use der_parser::oid;
use der_parser::oid::Oid;
use log::trace;
use rcgen::KeyPair;
use ring::rand::SystemRandom;
use ring::signature::{EcdsaKeyPair, Ed25519KeyPair};
Expand Down Expand Up @@ -337,7 +338,7 @@ fn verify_signature(
_ => return Err(Error::ErrKeySignatureVerifyUnimplemented),
};

log::trace!("Picked an algorithm {:?}", verify_alg);
trace!("Picked an algorithm {:?}", verify_alg);

let public_key = ring::signature::UnparsedPublicKey::new(
verify_alg,
Expand Down
3 changes: 2 additions & 1 deletion rtc-dtls/src/flight/flight0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::record_layer::record_layer_header::*;
use crate::*;
use shared::error::Error;

use log::debug;
use rand::Rng;
use std::fmt;

Expand Down Expand Up @@ -74,7 +75,7 @@ impl Flight for Flight0 {
find_matching_cipher_suite(&client_hello.cipher_suites, &cfg.local_cipher_suites)
{
if let Ok(cipher_suite) = cipher_suite_for_id(id) {
log::debug!(
debug!(
"[handshake:{}] use cipher suite: {}",
srv_cli_str(state.is_client),
cipher_suite.to_string()
Expand Down
3 changes: 2 additions & 1 deletion rtc-dtls/src/handshake/handshake_message_client_hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::extension::*;
use crate::record_layer::record_layer_header::*;

use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use log::warn;
use std::fmt;
use std::io::{BufReader, BufWriter};

Expand Down Expand Up @@ -169,7 +170,7 @@ impl HandshakeMessageClientHello {
if let Ok(extension) = Extension::unmarshal(&mut extension_reader) {
extensions.push(extension);
} else {
log::warn!(
warn!(
"Unsupported Extension Type {} {}",
extension_buffer[offset],
extension_buffer[offset + 1]
Expand Down
3 changes: 2 additions & 1 deletion rtc-dtls/src/handshake/handshake_message_server_hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::extension::*;
use crate::record_layer::record_layer_header::*;

use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use log::warn;
use std::fmt;
use std::io::{BufReader, BufWriter};

Expand Down Expand Up @@ -125,7 +126,7 @@ impl HandshakeMessageServerHello {
if let Ok(extension) = Extension::unmarshal(&mut extension_reader) {
extensions.push(extension);
} else {
log::warn!(
warn!(
"Unsupported Extension Type {} {}",
extension_buffer[offset],
extension_buffer[offset + 1]
Expand Down
2 changes: 1 addition & 1 deletion rtc-ice/src/agent/agent_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Agent {
> self.relay_acceptance_min_wait.as_nanos()
}
CandidateType::Unspecified => {
log::error!(
error!(
"is_nominatable invalid candidate type {}",
c.candidate_type()
);
Expand Down
32 changes: 19 additions & 13 deletions rtc-turn/examples/turn_client_udp.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
/*
use std::sync::Arc;
use clap::{App, AppSettings, Arg};
use tokio::net::UdpSocket;
use tokio::time::Duration;
use turn::client::*;
use turn::Error;
use util::Conn;
use clap::Parser;
use rtc_turn::client::*;
use shared::error::Result;

// RUST_LOG=trace cargo run --color=always --package turn --example turn_client_udp -- --host 0.0.0.0 --user user=pass --ping

#[tokio::main]
async fn main() -> Result<(), Error> {
#[derive(Parser)]
#[command(name = "ICE Ping Pong")]
#[command(author = "Rusty Rain <[email protected]>")]
#[command(version = "0.1.0")]
#[command(about = "An example of ICE", long_about = None)]
struct Cli {
#[arg(short, long)]
controlling: bool,

#[arg(short, long)]
debug: bool,
#[arg(long, default_value_t = format!("INFO"))]
log_level: String,
}

fn main() -> Result<()> {
env_logger::init();

let mut app = App::new("TURN Client UDP")
Expand Down Expand Up @@ -196,5 +204,3 @@ async fn do_ping_test(

Ok(())
}
*/
fn main() {}
4 changes: 2 additions & 2 deletions rtc-turn/src/client/client_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn test_client_with_stun_send_binding_request() -> Result<()> {
match event {
Event::BindingResponse(id, refl_addr) => {
assert_eq!(tid, id);
log::debug!("mapped-addr: {}", refl_addr);
debug!("mapped-addr: {}", refl_addr);
}
_ => assert!(false),
}
Expand Down Expand Up @@ -118,7 +118,7 @@ fn test_client_with_stun_send_binding_request_to_parallel() -> Result<()> {
match event {
Event::BindingResponse(tid, refl_addr) => {
tids.insert(tid);
log::debug!("mapped-addr: {}", refl_addr);
debug!("mapped-addr: {}", refl_addr);
}
_ => {}
}
Expand Down
17 changes: 9 additions & 8 deletions rtc-turn/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod relay;
pub mod transaction;

use bytes::BytesMut;
use log::{debug, trace};
use std::collections::{HashMap, VecDeque};
use std::net::SocketAddr;
use std::time::Instant;
Expand Down Expand Up @@ -243,7 +244,7 @@ impl Client {
Err(Error::ErrNonStunmessage)
} else {
// assume, this is an application data
log::trace!("non-STUN/TURN packet, unhandled");
trace!("non-STUN/TURN packet, unhandled");
Ok(())
}
}
Expand All @@ -270,7 +271,7 @@ impl Client {
let mut data = Data::default();
data.get_from(&msg)?;

log::debug!("data indication received from {}", from);
debug!("data indication received from {}", from);

self.events.push_back(Event::DataIndicationOrChannelData(
None,
Expand All @@ -289,7 +290,7 @@ impl Client {

if self.tr_map.find(&msg.transaction_id).is_none() {
// silently discard
log::debug!("no transaction for {}", msg);
debug!("no transaction for {}", msg);
return Ok(());
}

Expand Down Expand Up @@ -373,7 +374,7 @@ impl Client {
.find_addr_by_channel_number(ch_data.number.0)
.ok_or(Error::ErrChannelBindNotFound)?;

log::trace!(
trace!(
"channel data received from {} (ch={})",
addr,
ch_data.number.0
Expand Down Expand Up @@ -423,7 +424,7 @@ impl Client {
msg
};

log::debug!("client.SendBindingRequestTo call PerformTransaction 1");
debug!("client.SendBindingRequestTo call PerformTransaction 1");
Ok(self.perform_transaction(&msg, to, TransactionType::BindingRequest))
}

Expand Down Expand Up @@ -505,7 +506,7 @@ impl Client {
Box::new(FINGERPRINT),
])?;

log::debug!("client.Allocate call PerformTransaction 1");
debug!("client.Allocate call PerformTransaction 1");
let tid = self.perform_transaction(
&msg,
self.turn_server_addr()?,
Expand Down Expand Up @@ -564,7 +565,7 @@ impl Client {
Box::new(FINGERPRINT),
])?;

log::debug!("client.Allocate call PerformTransaction 2");
debug!("client.Allocate call PerformTransaction 2");
self.perform_transaction(
&msg,
self.turn_server_addr()?,
Expand Down Expand Up @@ -653,7 +654,7 @@ impl Client {
interval: self.rto_in_ms,
});

log::trace!(
trace!(
"start {} transaction {:?} to {}",
msg.typ,
msg.transaction_id,
Expand Down
3 changes: 2 additions & 1 deletion rtc-turn/src/client/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bytes::BytesMut;
use log::trace;
use std::collections::{HashMap, VecDeque};
use std::net::SocketAddr;
use std::ops::Add;
Expand Down Expand Up @@ -95,7 +96,7 @@ impl Transaction {
return;
}

log::trace!(
trace!(
"retransmitting transaction {:?} to {} (n_rtx={})",
self.transaction_id,
self.peer_addr,
Expand Down

0 comments on commit a36415a

Please sign in to comment.