Skip to content

Commit 0c3ef3c

Browse files
mneumannbrson
authored andcommitted
Convert log(debug, ...) to debug!(...)
1 parent 02de11c commit 0c3ef3c

File tree

1 file changed

+62
-69
lines changed

1 file changed

+62
-69
lines changed

src/libstd/net_tcp.rs

Lines changed: 62 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,20 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
169169
iotask: iotask.clone()
170170
};
171171
let socket_data_ptr = ptr::addr_of(&(*socket_data));
172-
log(debug, fmt!("tcp_connect result_ch %?", conn_data.result_ch));
172+
debug!("tcp_connect result_ch %?", conn_data.result_ch);
173173
// get an unsafe representation of our stream_handle_ptr that
174174
// we can send into the interact cb to be handled in libuv..
175-
log(debug, fmt!("stream_handle_ptr outside interact %?",
176-
stream_handle_ptr));
175+
debug!("stream_handle_ptr outside interact %?",
176+
stream_handle_ptr);
177177
do iotask::interact(iotask) |move input_ip, loop_ptr| {
178178
unsafe {
179-
log(debug, ~"in interact cb for tcp client connect..");
180-
log(debug, fmt!("stream_handle_ptr in interact %?",
181-
stream_handle_ptr));
179+
debug!("in interact cb for tcp client connect..");
180+
debug!("stream_handle_ptr in interact %?",
181+
stream_handle_ptr);
182182
match uv::ll::tcp_init( loop_ptr, stream_handle_ptr) {
183183
0i32 => {
184-
log(debug, ~"tcp_init successful");
185-
log(debug, ~"dealing w/ ipv4 connection..");
184+
debug!("tcp_init successful");
185+
debug!("dealing w/ ipv4 connection..");
186186
let connect_req_ptr =
187187
ptr::addr_of(&((*socket_data_ptr).connect_req));
188188
let addr_str = ip::format_addr(&input_ip);
@@ -195,7 +195,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
195195
// type that actually is closer to
196196
// what the libuv API expects (ip str
197197
// + port num)
198-
log(debug, fmt!("addr: %?", addr));
198+
debug!("addr: %?", addr);
199199
let in_addr = uv::ll::ip4_addr(addr_str,
200200
port as int);
201201
uv::ll::tcp_connect(
@@ -205,7 +205,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
205205
tcp_connect_on_connect_cb)
206206
}
207207
ip::Ipv6(ref addr) => {
208-
log(debug, fmt!("addr: %?", addr));
208+
debug!("addr: %?", addr);
209209
let in_addr = uv::ll::ip6_addr(addr_str,
210210
port as int);
211211
uv::ll::tcp_connect6(
@@ -217,7 +217,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
217217
};
218218
match connect_result {
219219
0i32 => {
220-
log(debug, ~"tcp_connect successful");
220+
debug!("tcp_connect successful");
221221
// reusable data that we'll have for the
222222
// duration..
223223
uv::ll::set_data_for_uv_handle(
@@ -228,8 +228,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
228228
// outcome..
229229
uv::ll::set_data_for_req(connect_req_ptr,
230230
conn_data_ptr);
231-
log(debug,
232-
~"leaving tcp_connect interact cb...");
231+
debug!("leaving tcp_connect interact cb...");
233232
// let tcp_connect_on_connect_cb send on
234233
// the result_ch, now..
235234
}
@@ -260,12 +259,12 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
260259
}
261260
match oldcomm::recv(result_po) {
262261
ConnSuccess => {
263-
log(debug, ~"tcp::connect - received success on result_po");
262+
debug!("tcp::connect - received success on result_po");
264263
result::Ok(TcpSocket(socket_data))
265264
}
266265
ConnFailure(ref err_data) => {
267266
oldcomm::recv(closed_signal_po);
268-
log(debug, ~"tcp::connect - received failure on result_po");
267+
debug!("tcp::connect - received failure on result_po");
269268
// still have to free the malloc'd stream handle..
270269
rustrt::rust_uv_current_kernel_free(stream_handle_ptr
271270
as *libc::c_void);
@@ -379,8 +378,8 @@ pub fn read_stop(sock: &TcpSocket,
379378
read_port: oldcomm::Port<result::Result<~[u8], TcpErrData>>) ->
380379
result::Result<(), TcpErrData> {
381380
unsafe {
382-
log(debug,
383-
fmt!("taking the read_port out of commission %?", read_port));
381+
debug!(
382+
"taking the read_port out of commission %?", read_port);
384383
let socket_data = ptr::addr_of(&(*sock.socket_data));
385384
read_stop_common_impl(socket_data)
386385
}
@@ -548,7 +547,7 @@ pub fn accept(new_conn: TcpNewConnection)
548547
// the rules here because this always has to be
549548
// called within the context of a listen() new_connect_cb
550549
// callback (or it will likely fail and drown your cat)
551-
log(debug, ~"in interact cb for tcp::accept");
550+
debug!("in interact cb for tcp::accept");
552551
let loop_ptr = uv::ll::get_loop_for_uv_handle(
553552
server_handle_ptr);
554553
match uv::ll::tcp_init(loop_ptr, client_stream_handle_ptr) {
@@ -908,7 +907,7 @@ impl TcpSocketBuf: io::Reader {
908907
self.end_of_stream
909908
}
910909
fn seek(&self, dist: int, seek: io::SeekStyle) {
911-
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
910+
debug!("tcp_socket_buf seek stub %? %?", dist, seek);
912911
// noop
913912
}
914913
fn tell(&self) -> uint {
@@ -935,7 +934,7 @@ impl TcpSocketBuf: io::Writer {
935934
}
936935
}
937936
fn seek(&self, dist: int, seek: io::SeekStyle) {
938-
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
937+
debug!("tcp_socket_buf seek stub %? %?", dist, seek);
939938
// noop
940939
}
941940
fn tell(&self) -> uint {
@@ -1524,7 +1523,7 @@ pub mod test {
15241523
};
15251524
oldcomm::recv(cont_po);
15261525
// client
1527-
log(debug, ~"server started, firing up client..");
1526+
debug!("server started, firing up client..");
15281527
let actual_resp_result = do oldcomm::listen |client_ch| {
15291528
run_tcp_test_client(
15301529
server_ip,
@@ -1536,10 +1535,10 @@ pub mod test {
15361535
assert actual_resp_result.is_ok();
15371536
let actual_resp = actual_resp_result.get();
15381537
let actual_req = oldcomm::recv(server_result_po);
1539-
log(debug, fmt!("REQ: expected: '%s' actual: '%s'",
1540-
expected_req, actual_req));
1541-
log(debug, fmt!("RESP: expected: '%s' actual: '%s'",
1542-
expected_resp, actual_resp));
1538+
debug!("REQ: expected: '%s' actual: '%s'",
1539+
expected_req, actual_req);
1540+
debug!("RESP: expected: '%s' actual: '%s'",
1541+
expected_resp, actual_resp);
15431542
assert str::contains(actual_req, expected_req);
15441543
assert str::contains(actual_resp, expected_resp);
15451544
}
@@ -1570,7 +1569,7 @@ pub mod test {
15701569
};
15711570
oldcomm::recv(cont_po);
15721571
// client
1573-
log(debug, ~"server started, firing up client..");
1572+
debug!("server started, firing up client..");
15741573
do oldcomm::listen |client_ch| {
15751574
let server_ip_addr = ip::v4::parse_addr(server_ip);
15761575
let iotask = uv::global_loop::get();
@@ -1600,7 +1599,7 @@ pub mod test {
16001599
let server_port = 8889u;
16011600
let expected_req = ~"ping";
16021601
// client
1603-
log(debug, ~"firing up client..");
1602+
debug!("firing up client..");
16041603
let actual_resp_result = do oldcomm::listen |client_ch| {
16051604
run_tcp_test_client(
16061605
server_ip,
@@ -1647,7 +1646,7 @@ pub mod test {
16471646
server_port,
16481647
hl_loop);
16491648
// client.. just doing this so that the first server tears down
1650-
log(debug, ~"server started, firing up client..");
1649+
debug!("server started, firing up client..");
16511650
do oldcomm::listen |client_ch| {
16521651
run_tcp_test_client(
16531652
server_ip,
@@ -1766,7 +1765,7 @@ pub mod test {
17661765
};
17671766
oldcomm::recv(cont_po);
17681767
// client
1769-
log(debug, ~"server started, firing up client..");
1768+
debug!("server started, firing up client..");
17701769
let server_addr = ip::v4::parse_addr(server_ip);
17711770
let conn_result = connect(move server_addr, server_port, hl_loop);
17721771
if result::is_err(&conn_result) {
@@ -1777,23 +1776,23 @@ pub mod test {
17771776

17781777
let buf_reader = sock_buf as Reader;
17791778
let actual_response = str::from_bytes(buf_reader.read_whole_stream());
1780-
log(debug, fmt!("Actual response: %s", actual_response));
1779+
debug!("Actual response: %s", actual_response);
17811780
assert expected_resp == actual_response;
17821781
}
17831782

17841783
fn buf_write<W:io::Writer>(w: &W, val: &str) {
1785-
log(debug, fmt!("BUF_WRITE: val len %?", str::len(val)));
1784+
debug!("BUF_WRITE: val len %?", str::len(val));
17861785
do str::byte_slice(val) |b_slice| {
1787-
log(debug, fmt!("BUF_WRITE: b_slice len %?",
1788-
vec::len(b_slice)));
1786+
debug!("BUF_WRITE: b_slice len %?",
1787+
vec::len(b_slice));
17891788
w.write(b_slice)
17901789
}
17911790
}
17921791

17931792
fn buf_read<R:io::Reader>(r: &R, len: uint) -> ~str {
17941793
let new_bytes = (*r).read_bytes(len);
1795-
log(debug, fmt!("in buf_read.. new_bytes len: %?",
1796-
vec::len(new_bytes)));
1794+
debug!("in buf_read.. new_bytes len: %?",
1795+
vec::len(new_bytes));
17971796
str::from_bytes(new_bytes)
17981797
}
17991798

@@ -1806,65 +1805,61 @@ pub mod test {
18061805
iotask,
18071806
// on_establish_cb -- called when listener is set up
18081807
|kill_ch| {
1809-
log(debug, fmt!("establish_cb %?",
1810-
kill_ch));
1808+
debug!("establish_cb %?", kill_ch);
18111809
oldcomm::send(cont_ch, ());
18121810
},
18131811
// risky to run this on the loop, but some users
18141812
// will want the POWER
18151813
|new_conn, kill_ch| {
1816-
log(debug, ~"SERVER: new connection!");
1814+
debug!("SERVER: new connection!");
18171815
do oldcomm::listen |cont_ch| {
18181816
do task::spawn_sched(task::ManualThreads(1u)) {
1819-
log(debug, ~"SERVER: starting worker for new req");
1817+
debug!("SERVER: starting worker for new req");
18201818

18211819
let accept_result = accept(new_conn);
1822-
log(debug, ~"SERVER: after accept()");
1820+
debug!("SERVER: after accept()");
18231821
if result::is_err(&accept_result) {
1824-
log(debug, ~"SERVER: error accept connection");
1822+
debug!("SERVER: error accept connection");
18251823
let err_data = result::get_err(&accept_result);
18261824
oldcomm::send(kill_ch, Some(err_data));
1827-
log(debug,
1828-
~"SERVER/WORKER: send on err cont ch");
1825+
debug!("SERVER/WORKER: send on err cont ch");
18291826
cont_ch.send(());
18301827
}
18311828
else {
1832-
log(debug,
1833-
~"SERVER/WORKER: send on cont ch");
1829+
debug!("SERVER/WORKER: send on cont ch");
18341830
cont_ch.send(());
18351831
let sock = result::unwrap(move accept_result);
18361832
let peer_addr = sock.get_peer_addr();
1837-
log(debug, ~"SERVER: successfully accepted"+
1838-
fmt!(" connection from %s:%u",
1833+
debug!("SERVER: successfully accepted connection from %s:%u",
18391834
ip::format_addr(&peer_addr),
1840-
ip::get_port(&peer_addr)));
1835+
ip::get_port(&peer_addr));
18411836
let received_req_bytes = read(&sock, 0u);
18421837
match move received_req_bytes {
18431838
result::Ok(move data) => {
1844-
log(debug, ~"SERVER: got REQ str::from_bytes..");
1845-
log(debug, fmt!("SERVER: REQ data len: %?",
1846-
vec::len(data)));
1839+
debug!("SERVER: got REQ str::from_bytes..");
1840+
debug!("SERVER: REQ data len: %?",
1841+
vec::len(data));
18471842
server_ch.send(
18481843
str::from_bytes(data));
1849-
log(debug, ~"SERVER: before write");
1844+
debug!("SERVER: before write");
18501845
tcp_write_single(&sock, str::to_bytes(resp));
1851-
log(debug, ~"SERVER: after write.. die");
1846+
debug!("SERVER: after write.. die");
18521847
oldcomm::send(kill_ch, None);
18531848
}
18541849
result::Err(move err_data) => {
1855-
log(debug, fmt!("SERVER: error recvd: %s %s",
1856-
err_data.err_name, err_data.err_msg));
1850+
debug!("SERVER: error recvd: %s %s",
1851+
err_data.err_name, err_data.err_msg);
18571852
oldcomm::send(kill_ch, Some(err_data));
18581853
server_ch.send(~"");
18591854
}
18601855
}
1861-
log(debug, ~"SERVER: worker spinning down");
1856+
debug!("SERVER: worker spinning down");
18621857
}
18631858
}
1864-
log(debug, ~"SERVER: waiting to recv on cont_ch");
1859+
debug!("SERVER: waiting to recv on cont_ch");
18651860
cont_ch.recv()
18661861
};
1867-
log(debug, ~"SERVER: recv'd on cont_ch..leaving listen cb");
1862+
debug!("SERVER: recv'd on cont_ch..leaving listen cb");
18681863
});
18691864
// err check on listen_result
18701865
if result::is_err(&listen_result) {
@@ -1882,7 +1877,7 @@ pub mod test {
18821877
}
18831878
}
18841879
let ret_val = server_ch.recv();
1885-
log(debug, fmt!("SERVER: exited and got return val: '%s'", ret_val));
1880+
debug!("SERVER: exited and got return val: '%s'", ret_val);
18861881
ret_val
18871882
}
18881883

@@ -1893,8 +1888,7 @@ pub mod test {
18931888
iotask,
18941889
// on_establish_cb -- called when listener is set up
18951890
|kill_ch| {
1896-
log(debug, fmt!("establish_cb %?",
1897-
kill_ch));
1891+
debug!("establish_cb %?", kill_ch);
18981892
},
18991893
|new_conn, kill_ch| {
19001894
fail fmt!("SERVER: shouldn't be called.. %? %?",
@@ -1915,11 +1909,11 @@ pub mod test {
19151909
TcpConnectErrData> {
19161910
let server_ip_addr = ip::v4::parse_addr(server_ip);
19171911

1918-
log(debug, ~"CLIENT: starting..");
1912+
debug!("CLIENT: starting..");
19191913
let connect_result = connect(move server_ip_addr, server_port,
19201914
iotask);
19211915
if result::is_err(&connect_result) {
1922-
log(debug, ~"CLIENT: failed to connect");
1916+
debug!("CLIENT: failed to connect");
19231917
let err_data = result::get_err(&connect_result);
19241918
Err(err_data)
19251919
}
@@ -1929,14 +1923,13 @@ pub mod test {
19291923
tcp_write_single(&sock, resp_bytes);
19301924
let read_result = sock.read(0u);
19311925
if read_result.is_err() {
1932-
log(debug, ~"CLIENT: failure to read");
1926+
debug!("CLIENT: failure to read");
19331927
Ok(~"")
19341928
}
19351929
else {
19361930
client_ch.send(str::from_bytes(read_result.get()));
19371931
let ret_val = client_ch.recv();
1938-
log(debug, fmt!("CLIENT: after client_ch recv ret: '%s'",
1939-
ret_val));
1932+
debug!("CLIENT: after client_ch recv ret: '%s'", ret_val);
19401933
Ok(ret_val)
19411934
}
19421935
}
@@ -1946,10 +1939,10 @@ pub mod test {
19461939
let write_result_future = sock.write_future(val);
19471940
let write_result = write_result_future.get();
19481941
if result::is_err(&write_result) {
1949-
log(debug, ~"tcp_write_single: write failed!");
1942+
debug!("tcp_write_single: write failed!");
19501943
let err_data = result::get_err(&write_result);
1951-
log(debug, fmt!("tcp_write_single err name: %s msg: %s",
1952-
err_data.err_name, err_data.err_msg));
1944+
debug!("tcp_write_single err name: %s msg: %s",
1945+
err_data.err_name, err_data.err_msg);
19531946
// meh. torn on what to do here.
19541947
fail ~"tcp_write_single failed";
19551948
}

0 commit comments

Comments
 (0)