Skip to content

Commit

Permalink
allow controlling logging verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Jun 11, 2024
1 parent 479c5ee commit 94f9e82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions host/src/channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ impl<const QLEN: usize> PacketChannel<QLEN> {
}

impl<'d> State<'d> {
fn print(&self) {
fn print(&self, verbose: bool) {
for (idx, storage) in self.channels.iter().enumerate() {
if storage.state != ChannelState::Disconnected {
if verbose || storage.state != ChannelState::Disconnected {
debug!("[l2cap][idx = {}] state = {:?}", idx, storage);
}
}
Expand Down Expand Up @@ -673,9 +673,9 @@ impl<'d, const RXQ: usize> ChannelManager<'d, RXQ> {
});
}

pub(crate) fn log_status(&self) {
pub(crate) fn log_status(&self, verbose: bool) {
let state = self.state.borrow();
state.print();
state.print(verbose);
}
}

Expand Down
8 changes: 4 additions & 4 deletions host/src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ struct State<'d> {
}

impl<'d> State<'d> {
fn print(&self) {
fn print(&self, verbose: bool) {
for (idx, storage) in self.connections.iter().enumerate() {
if storage.state != ConnectionState::Disconnected {
if verbose || storage.state != ConnectionState::Disconnected {
debug!("[link][idx = {}] state = {:?}", idx, storage);
}
}
Expand Down Expand Up @@ -199,9 +199,9 @@ impl<'d> ConnectionManager<'d> {
f(&mut state)
}

pub(crate) fn log_status(&self) {
pub(crate) fn log_status(&self, verbose: bool) {
let state = self.state.borrow();
state.print();
state.print(verbose);
}

pub(crate) fn inc_ref(&self, index: u8) {
Expand Down
7 changes: 4 additions & 3 deletions host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ where
) -> bool {
match status.to_result() {
Ok(_) => {
trace!("[host] connected event on handle {:?}", handle);
if let Err(err) = self.connections.connect(handle, peer_addr_kind, peer_addr, role) {
warn!("Error establishing connection: {:?}", err);
return false;
Expand Down Expand Up @@ -1144,13 +1145,13 @@ where
}

/// Log status information of the host
pub fn log_status(&self) {
pub fn log_status(&self, verbose: bool) {
let m = self.metrics.borrow();
debug!("[host] connect events: {}", m.connect_events);
debug!("[host] disconnect events: {}", m.disconnect_events);
debug!("[host] rx errors: {}", m.rx_errors);
self.connections.log_status();
self.channels.log_status();
self.connections.log_status(verbose);
self.channels.log_status(verbose);
}
}

Expand Down

0 comments on commit 94f9e82

Please sign in to comment.