refactor: 迁出日志宏,移除直接依赖

This commit is contained in:
爱特每羊队
2026-06-26 18:53:48 +08:00
parent 8394c5d632
commit e730d0fd2d
24 changed files with 214 additions and 280 deletions
+2 -11
View File
@@ -15,12 +15,7 @@ pub struct SubsystemFilter {
impl SubsystemFilter {
pub fn new() -> Self {
Self {
levels: Arc::new([
AtomicU8::new(0),
AtomicU8::new(0),
AtomicU8::new(0),
AtomicU8::new(0),
]),
levels: Arc::new([AtomicU8::new(0), AtomicU8::new(0), AtomicU8::new(0), AtomicU8::new(0)]),
}
}
@@ -63,11 +58,7 @@ impl Default for SubsystemFilter {
}
impl<S: Subscriber> Filter<S> for SubsystemFilter {
fn enabled(
&self,
meta: &tracing::Metadata<'_>,
_cx: &tracing_subscriber::layer::Context<'_, S>,
) -> bool {
fn enabled(&self, meta: &tracing::Metadata<'_>, _cx: &tracing_subscriber::layer::Context<'_, S>) -> bool {
self.is_enabled_for(meta.target(), meta.level())
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ pub enum Level {
}
impl Level {
pub fn as_tracing_level(self) -> tracing::Level {
pub const fn as_tracing_level(self) -> tracing::Level {
match self {
Level::Off | Level::Error => tracing::Level::ERROR,
Level::Warn => tracing::Level::WARN,
+3
View File
@@ -8,3 +8,6 @@ pub use filter::SubsystemFilter;
pub use init::{init, set_level, LogConfig, Output};
pub use level::Level;
pub use subsystem::{SubsystemId, SUBSYSTEM_COUNT};
#[doc(hidden)]
pub use tracing;
+1 -1
View File
@@ -1,6 +1,6 @@
#[macro_export]
macro_rules! __log_event {
($target:expr, $level:expr, $($arg:tt)*) => {
tracing::event!(target: $target, $level, $($arg)*)
$crate::tracing::event!(target: $target, $level, $($arg)*)
};
}