Skip to content

Commit

Permalink
Remove log feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Dec 11, 2023
1 parent 736ac94 commit 129f859
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include = [
# For documentation of features see the `mio::features` module.
[features]
# By default Mio only provides a shell implementation.
default = ["log"]
default = []

# Enables the `Poll` and `Registry` types.
os-poll = []
Expand All @@ -45,7 +45,7 @@ os-ext = [
net = []

[dependencies]
log = { version = "0.4.8", optional = true }
log = { version = "0.4.8" }

[target.'cfg(unix)'.dependencies]
libc = "0.2.149"
Expand Down
2 changes: 1 addition & 1 deletion examples/udp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn main() -> io::Result<()> {
// This should never happen as we only registered our
// `UdpSocket` using the `UDP_SOCKET` token, but if it ever
// does we'll log it.
warn!("Got event for unexpected token: {:?}", event);
log::warn!("Got event for unexpected token: {:?}", event);
}
}
}
Expand Down
28 changes: 0 additions & 28 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,3 @@ macro_rules! cfg_any_os_ext {
)*
}
}

macro_rules! trace {
($($t:tt)*) => {
log!(trace, $($t)*)
}
}

macro_rules! warn {
($($t:tt)*) => {
log!(warn, $($t)*)
}
}

macro_rules! error {
($($t:tt)*) => {
log!(error, $($t)*)
}
}

macro_rules! log {
($level: ident, $($t:tt)*) => {
#[cfg(feature = "log")]
{ log::$level!($($t)*) }
// Silence unused variables warnings.
#[cfg(not(feature = "log"))]
{ if false { let _ = ( $($t)* ); } }
}
}
6 changes: 3 additions & 3 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl Registry {
where
S: event::Source + ?Sized,
{
trace!(
log::trace!(
"registering event source with poller: token={:?}, interests={:?}",
token,
interests
Expand Down Expand Up @@ -616,7 +616,7 @@ impl Registry {
where
S: event::Source + ?Sized,
{
trace!(
log::trace!(
"reregistering event source with poller: token={:?}, interests={:?}",
token,
interests
Expand Down Expand Up @@ -679,7 +679,7 @@ impl Registry {
where
S: event::Source + ?Sized,
{
trace!("deregistering event source from poller");
log::trace!("deregistering event source from poller");
source.deregister(self)
}

Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/selector/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl AsRawFd for Selector {
impl Drop for Selector {
fn drop(&mut self) {
if let Err(err) = syscall!(close(self.ep)) {
error!("error closing epoll: {}", err);
log::error!("error closing epoll: {}", err);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/selector/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl AsRawFd for Selector {
impl Drop for Selector {
fn drop(&mut self) {
if let Err(err) = syscall!(close(self.kq)) {
error!("error closing kqueue: {}", err);
log::error!("error closing kqueue: {}", err);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/sys/unix/selector/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ impl SelectorState {
}

// Perform the poll.
trace!("Polling on {:?}", &fds);
log::trace!("Polling on {:?}", &fds);
let num_events = poll(&mut fds.poll_fds, timeout)?;
trace!("Poll finished: {:?}", &fds);
log::trace!("Poll finished: {:?}", &fds);

if num_events == 0 {
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion src/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Selector {
debug_assert!(events.capacity() >= length);
#[cfg(debug_assertions)]
if length == 0 {
warn!(
log::warn!(
"calling mio::Poll::poll with empty subscriptions, this likely not what you want"
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn expect_events(poll: &mut Poll, events: &mut Events, mut expected: Vec<Exp
expected.swap_remove(index);
} else {
// Must accept sporadic events.
warn!("got unexpected event: {:?}", event);
log::warn!("got unexpected event: {:?}", event);
}
}

Expand All @@ -170,7 +170,7 @@ pub fn expect_no_events(poll: &mut Poll, events: &mut Events) {
.expect("unable to poll");
if !events.is_empty() {
for event in events.iter() {
error!("unexpected event: {:?}", event);
log::error!("unexpected event: {:?}", event);
}
panic!("received events, but didn't expect any, see above");
}
Expand Down

0 comments on commit 129f859

Please sign in to comment.