feat(lib): switch from log to tracing (#475)
This commit is contained in:
@@ -84,7 +84,7 @@ impl Prioritize {
|
||||
|
||||
flow.assign_capacity(config.remote_init_window_sz);
|
||||
|
||||
log::trace!("Prioritize::new; flow={:?}", flow);
|
||||
tracing::trace!("Prioritize::new; flow={:?}", flow);
|
||||
|
||||
Prioritize {
|
||||
pending_send: store::Queue::new(),
|
||||
@@ -112,7 +112,7 @@ impl Prioritize {
|
||||
pub fn schedule_send(&mut self, stream: &mut store::Ptr, task: &mut Option<Waker>) {
|
||||
// If the stream is waiting to be opened, nothing more to do.
|
||||
if stream.is_send_ready() {
|
||||
log::trace!("schedule_send; {:?}", stream.id);
|
||||
tracing::trace!("schedule_send; {:?}", stream.id);
|
||||
// Queue the stream
|
||||
self.pending_send.push(stream);
|
||||
|
||||
@@ -158,7 +158,7 @@ impl Prioritize {
|
||||
// Update the buffered data counter
|
||||
stream.buffered_send_data += sz;
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"send_data; sz={}; buffered={}; requested={}",
|
||||
sz,
|
||||
stream.buffered_send_data,
|
||||
@@ -179,7 +179,7 @@ impl Prioritize {
|
||||
self.reserve_capacity(0, stream, counts);
|
||||
}
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"send_data (2); available={}; buffered={}",
|
||||
stream.send_flow.available(),
|
||||
stream.buffered_send_data
|
||||
@@ -214,7 +214,7 @@ impl Prioritize {
|
||||
stream: &mut store::Ptr,
|
||||
counts: &mut Counts,
|
||||
) {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"reserve_capacity; stream={:?}; requested={:?}; effective={:?}; curr={:?}",
|
||||
stream.id,
|
||||
capacity,
|
||||
@@ -266,7 +266,7 @@ impl Prioritize {
|
||||
inc: WindowSize,
|
||||
stream: &mut store::Ptr,
|
||||
) -> Result<(), Reason> {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"recv_stream_window_update; stream={:?}; state={:?}; inc={}; flow={:?}",
|
||||
stream.id,
|
||||
stream.state,
|
||||
@@ -326,7 +326,7 @@ impl Prioritize {
|
||||
pub fn clear_pending_capacity(&mut self, store: &mut Store, counts: &mut Counts) {
|
||||
while let Some(stream) = self.pending_capacity.pop(store) {
|
||||
counts.transition(stream, |_, stream| {
|
||||
log::trace!("clear_pending_capacity; stream={:?}", stream.id);
|
||||
tracing::trace!("clear_pending_capacity; stream={:?}", stream.id);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ impl Prioritize {
|
||||
) where
|
||||
R: Resolve,
|
||||
{
|
||||
log::trace!("assign_connection_capacity; inc={}", inc);
|
||||
tracing::trace!("assign_connection_capacity; inc={}", inc);
|
||||
|
||||
self.flow.assign_capacity(inc);
|
||||
|
||||
@@ -383,7 +383,7 @@ impl Prioritize {
|
||||
stream.send_flow.window_size() - stream.send_flow.available().as_size(),
|
||||
);
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"try_assign_capacity; stream={:?}, requested={}; additional={}; buffered={}; window={}; conn={}",
|
||||
stream.id,
|
||||
total_requested,
|
||||
@@ -416,7 +416,7 @@ impl Prioritize {
|
||||
// TODO: Should prioritization factor into this?
|
||||
let assign = cmp::min(conn_available, additional);
|
||||
|
||||
log::trace!(" assigning; stream={:?}, capacity={}", stream.id, assign,);
|
||||
tracing::trace!(" assigning; stream={:?}, capacity={}", stream.id, assign,);
|
||||
|
||||
// Assign the capacity to the stream
|
||||
stream.assign_capacity(assign);
|
||||
@@ -425,7 +425,7 @@ impl Prioritize {
|
||||
self.flow.claim_capacity(assign);
|
||||
}
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"try_assign_capacity(2); available={}; requested={}; buffered={}; has_unavailable={:?}",
|
||||
stream.send_flow.available(),
|
||||
stream.requested_send_capacity,
|
||||
@@ -485,14 +485,14 @@ impl Prioritize {
|
||||
// The max frame length
|
||||
let max_frame_len = dst.max_send_frame_size();
|
||||
|
||||
log::trace!("poll_complete");
|
||||
tracing::trace!("poll_complete");
|
||||
|
||||
loop {
|
||||
self.schedule_pending_open(store, counts);
|
||||
|
||||
match self.pop_frame(buffer, store, max_frame_len, counts) {
|
||||
Some(frame) => {
|
||||
log::trace!("writing frame={:?}", frame);
|
||||
tracing::trace!("writing frame={:?}", frame);
|
||||
|
||||
debug_assert_eq!(self.in_flight_data_frame, InFlightData::Nothing);
|
||||
if let Frame::Data(ref frame) = frame {
|
||||
@@ -538,11 +538,11 @@ impl Prioritize {
|
||||
where
|
||||
B: Buf,
|
||||
{
|
||||
log::trace!("try reclaim frame");
|
||||
tracing::trace!("try reclaim frame");
|
||||
|
||||
// First check if there are any data chunks to take back
|
||||
if let Some(frame) = dst.take_last_data_frame() {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
" -> reclaimed; frame={:?}; sz={}",
|
||||
frame,
|
||||
frame.payload().inner.get_ref().remaining()
|
||||
@@ -554,7 +554,7 @@ impl Prioritize {
|
||||
match mem::replace(&mut self.in_flight_data_frame, InFlightData::Nothing) {
|
||||
InFlightData::Nothing => panic!("wasn't expecting a frame to reclaim"),
|
||||
InFlightData::Drop => {
|
||||
log::trace!("not reclaiming frame for cancelled stream");
|
||||
tracing::trace!("not reclaiming frame for cancelled stream");
|
||||
return false;
|
||||
}
|
||||
InFlightData::DataFrame(k) => {
|
||||
@@ -603,11 +603,11 @@ impl Prioritize {
|
||||
}
|
||||
|
||||
pub fn clear_queue<B>(&mut self, buffer: &mut Buffer<Frame<B>>, stream: &mut store::Ptr) {
|
||||
log::trace!("clear_queue; stream={:?}", stream.id);
|
||||
tracing::trace!("clear_queue; stream={:?}", stream.id);
|
||||
|
||||
// TODO: make this more efficient?
|
||||
while let Some(frame) = stream.pending_send.pop_front(buffer) {
|
||||
log::trace!("dropping; frame={:?}", frame);
|
||||
tracing::trace!("dropping; frame={:?}", frame);
|
||||
}
|
||||
|
||||
stream.buffered_send_data = 0;
|
||||
@@ -644,12 +644,12 @@ impl Prioritize {
|
||||
where
|
||||
B: Buf,
|
||||
{
|
||||
log::trace!("pop_frame");
|
||||
tracing::trace!("pop_frame");
|
||||
|
||||
loop {
|
||||
match self.pending_send.pop(store) {
|
||||
Some(mut stream) => {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"pop_frame; stream={:?}; stream.state={:?}",
|
||||
stream.id,
|
||||
stream.state
|
||||
@@ -662,7 +662,7 @@ impl Prioritize {
|
||||
// To be safe, we just always ask the stream.
|
||||
let is_pending_reset = stream.is_pending_reset_expiration();
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
" --> stream={:?}; is_pending_reset={:?};",
|
||||
stream.id,
|
||||
is_pending_reset
|
||||
@@ -675,7 +675,7 @@ impl Prioritize {
|
||||
let stream_capacity = stream.send_flow.available();
|
||||
let sz = frame.payload().remaining();
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
" --> data frame; stream={:?}; sz={}; eos={:?}; window={}; \
|
||||
available={}; requested={}; buffered={};",
|
||||
frame.stream_id(),
|
||||
@@ -690,7 +690,7 @@ impl Prioritize {
|
||||
// Zero length data frames always have capacity to
|
||||
// be sent.
|
||||
if sz > 0 && stream_capacity == 0 {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
" --> stream capacity is 0; requested={}",
|
||||
stream.requested_send_capacity
|
||||
);
|
||||
@@ -721,10 +721,10 @@ impl Prioritize {
|
||||
// capacity at this point.
|
||||
debug_assert!(len <= self.flow.window_size());
|
||||
|
||||
log::trace!(" --> sending data frame; len={}", len);
|
||||
tracing::trace!(" --> sending data frame; len={}", len);
|
||||
|
||||
// Update the flow control
|
||||
log::trace!(" -- updating stream flow --");
|
||||
tracing::trace!(" -- updating stream flow --");
|
||||
stream.send_flow.send_data(len);
|
||||
|
||||
// Decrement the stream's buffered data counter
|
||||
@@ -737,7 +737,7 @@ impl Prioritize {
|
||||
// line.
|
||||
self.flow.assign_capacity(len);
|
||||
|
||||
log::trace!(" -- updating connection flow --");
|
||||
tracing::trace!(" -- updating connection flow --");
|
||||
self.flow.send_data(len);
|
||||
|
||||
// Wrap the frame's data payload to ensure that the
|
||||
@@ -789,7 +789,7 @@ impl Prioritize {
|
||||
// had data buffered to be sent, but all the frames are cleared
|
||||
// in clear_queue(). Instead of doing O(N) traversal through queue
|
||||
// to remove, lets just ignore the stream here.
|
||||
log::trace!("removing dangling stream from pending_send");
|
||||
tracing::trace!("removing dangling stream from pending_send");
|
||||
// Since this should only happen as a consequence of `clear_queue`,
|
||||
// we must be in a closed state of some kind.
|
||||
debug_assert!(stream.state.is_closed());
|
||||
@@ -799,7 +799,7 @@ impl Prioritize {
|
||||
}
|
||||
};
|
||||
|
||||
log::trace!("pop_frame; frame={:?}", frame);
|
||||
tracing::trace!("pop_frame; frame={:?}", frame);
|
||||
|
||||
if cfg!(debug_assertions) && stream.state.is_idle() {
|
||||
debug_assert!(stream.id > self.last_opened_id);
|
||||
@@ -824,11 +824,11 @@ impl Prioritize {
|
||||
}
|
||||
|
||||
fn schedule_pending_open(&mut self, store: &mut Store, counts: &mut Counts) {
|
||||
log::trace!("schedule_pending_open");
|
||||
tracing::trace!("schedule_pending_open");
|
||||
// check for any pending open streams
|
||||
while counts.can_inc_num_send_streams() {
|
||||
if let Some(mut stream) = self.pending_open.pop(store) {
|
||||
log::trace!("schedule_pending_open; stream={:?}", stream.id);
|
||||
tracing::trace!("schedule_pending_open; stream={:?}", stream.id);
|
||||
|
||||
counts.inc_num_send_streams(&mut stream);
|
||||
self.pending_send.push(&mut stream);
|
||||
|
||||
Reference in New Issue
Block a user