Skip to content

Commit

Permalink
Only automatically call init during tests and benches
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed Jan 7, 2025
1 parent c956338 commit 3bac778
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions neqo-common/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,45 @@ pub fn init(level_filter: Option<log::LevelFilter>) {
#[macro_export]
// TODO: Enable `#[clippy::format_args]` once our MSRV is >= 1.84
macro_rules! qerror {
($($arg:tt)*) => ( { ::neqo_common::log::init(None); ::log::error!($($arg)*); } );
($($arg:tt)*) => ( {
#[cfg(any(test, feature = "bench"))]
::neqo_common::log::init(None);
::log::error!($($arg)*);
} );
}
#[macro_export]
// TODO: Enable `#[clippy::format_args]` once our MSRV is >= 1.84
macro_rules! qwarn {
($($arg:tt)*) => ( { ::neqo_common::log::init(None); ::log::warn!($($arg)*); } );
($($arg:tt)*) => ( {
#[cfg(any(test, feature = "bench"))]
::neqo_common::log::init(None);
::log::warn!($($arg)*);
} );
}
#[macro_export]
// TODO: Enable `#[clippy::format_args]` once our MSRV is >= 1.84
macro_rules! qinfo {
($($arg:tt)*) => ( { ::neqo_common::log::init(None); ::log::info!($($arg)*); } );
($($arg:tt)*) => ( {
#[cfg(any(test, feature = "bench"))]
::neqo_common::log::init(None);
::log::info!($($arg)*);
} );
}
#[macro_export]
// TODO: Enable `#[clippy::format_args]` once our MSRV is >= 1.84
macro_rules! qdebug {
($($arg:tt)*) => ( { ::neqo_common::log::init(None); ::log::debug!($($arg)*); } );
($($arg:tt)*) => ( {
#[cfg(any(test, feature = "bench"))]
::neqo_common::log::init(None);
::log::debug!($($arg)*);
} );
}
#[macro_export]
// TODO: Enable `#[clippy::format_args]` once our MSRV is >= 1.84
macro_rules! qtrace {
($($arg:tt)*) => ( { ::neqo_common::log::init(None); ::log::trace!($($arg)*); } );
($($arg:tt)*) => ( {
#[cfg(any(test, feature = "bench"))]
::neqo_common::log::init(None);
::log::trace!($($arg)*);
} );
}

0 comments on commit 3bac778

Please sign in to comment.