wp_log/
macro_def.rs

1// 统一日志 target,围绕 6 个域进行输出:
2// ctrl  - 平台控制面,覆盖启动/调度/治理等生命周期事件。
3// data  - 数据平面,覆盖 source/parse/connector/sink 的数据流处理。
4// rule  - 规则与业务策略执行,包含插件/接口等扩展点。
5// dfx   - 诊断与恢复能力,包含容错、兜底、应急处理。
6// mtrc  - 指标与观测数据,记录性能、吞吐、容量等信息。
7// kdb   - 知识库或知识图谱相关逻辑,集中管理特征/上下文。
8//
9// 为保证兼容,旧的 target 宏仍然导出,但已经标记为过期(#[deprecated]),
10// 并在内部转发到新的域。迁移新日志时请直接使用新的 target 宏。
11
12// ctrl 域(平台控制面)
13#[macro_export]
14macro_rules! trace_ctrl { ($($arg:tt)+) => { $crate::re_exports::log::trace!(target: "ctrl", $($arg)+) } }
15#[macro_export]
16macro_rules! debug_ctrl { ($($arg:tt)+) => { $crate::re_exports::log::debug!(target: "ctrl", $($arg)+) } }
17#[macro_export]
18macro_rules! info_ctrl  { ($($arg:tt)+) => { $crate::re_exports::log::info!( target: "ctrl", $($arg)+) } }
19#[macro_export]
20macro_rules! warn_ctrl  { ($($arg:tt)+) => { $crate::re_exports::log::warn!( target: "ctrl", $($arg)+) } }
21#[macro_export]
22macro_rules! error_ctrl { ($($arg:tt)+) => { $crate::re_exports::log::error!(target: "ctrl", $($arg)+) } }
23
24// data 域(数据平面)
25#[macro_export]
26macro_rules! trace_data { ($($arg:tt)+) => { $crate::re_exports::log::trace!(target: "data", $($arg)+) } }
27#[macro_export]
28macro_rules! debug_data { ($($arg:tt)+) => { $crate::re_exports::log::debug!(target: "data", $($arg)+) } }
29#[macro_export]
30macro_rules! info_data  { ($($arg:tt)+) => { $crate::re_exports::log::info!( target: "data", $($arg)+) } }
31#[macro_export]
32macro_rules! warn_data  { ($($arg:tt)+) => { $crate::re_exports::log::warn!( target: "data", $($arg)+) } }
33#[macro_export]
34macro_rules! error_data { ($($arg:tt)+) => { $crate::re_exports::log::error!(target: "data", $($arg)+) } }
35
36// rule 域(策略/插件/接口)
37#[macro_export]
38macro_rules! trace_rule { ($($arg:tt)+) => { $crate::re_exports::log::trace!(target: "rule", $($arg)+) } }
39#[macro_export]
40macro_rules! debug_rule { ($($arg:tt)+) => { $crate::re_exports::log::debug!(target: "rule", $($arg)+) } }
41#[macro_export]
42macro_rules! info_rule  { ($($arg:tt)+) => { $crate::re_exports::log::info!( target: "rule", $($arg)+) } }
43#[macro_export]
44macro_rules! warn_rule  { ($($arg:tt)+) => { $crate::re_exports::log::warn!( target: "rule", $($arg)+) } }
45#[macro_export]
46macro_rules! error_rule { ($($arg:tt)+) => { $crate::re_exports::log::error!(target: "rule", $($arg)+) } }
47
48// dfx 域(诊断 & 恢复)
49#[macro_export]
50macro_rules! trace_dfx { ($($arg:tt)+) => { $crate::re_exports::log::trace!(target: "dfx", $($arg)+) } }
51#[macro_export]
52macro_rules! debug_dfx { ($($arg:tt)+) => { $crate::re_exports::log::debug!(target: "dfx", $($arg)+) } }
53#[macro_export]
54macro_rules! info_dfx  { ($($arg:tt)+) => { $crate::re_exports::log::info!( target: "dfx", $($arg)+) } }
55#[macro_export]
56macro_rules! warn_dfx  { ($($arg:tt)+) => { $crate::re_exports::log::warn!( target: "dfx", $($arg)+) } }
57#[macro_export]
58macro_rules! error_dfx { ($($arg:tt)+) => { $crate::re_exports::log::error!(target: "dfx", $($arg)+) } }
59
60// mtrc 域(指标 & 观测)
61#[macro_export]
62macro_rules! trace_mtrc { ($($arg:tt)+) => { $crate::re_exports::log::trace!(target: "mtrc", $($arg)+) } }
63#[macro_export]
64macro_rules! debug_mtrc { ($($arg:tt)+) => { $crate::re_exports::log::debug!(target: "mtrc", $($arg)+) } }
65#[macro_export]
66macro_rules! info_mtrc  { ($($arg:tt)+) => { $crate::re_exports::log::info!( target: "mtrc", $($arg)+) } }
67#[macro_export]
68macro_rules! warn_mtrc  { ($($arg:tt)+) => { $crate::re_exports::log::warn!( target: "mtrc", $($arg)+) } }
69#[macro_export]
70macro_rules! error_mtrc { ($($arg:tt)+) => { $crate::re_exports::log::error!(target: "mtrc", $($arg)+) } }
71
72#[macro_export]
73macro_rules! println_mtrc {
74    ($($arg:tt)+) => {
75        let val = std::env::var($crate::conf::PRINT_STAT).unwrap_or("false".to_string());
76        if val.eq("true") {
77            println!("{}", format_args!($($arg)+));
78        }
79    }
80}
81
82// kdb 域(知识库)
83#[macro_export]
84macro_rules! trace_kdb { ($($arg:tt)+) => { $crate::re_exports::log::trace!(target: "kdb", $($arg)+) } }
85#[macro_export]
86macro_rules! debug_kdb { ($($arg:tt)+) => { $crate::re_exports::log::debug!(target: "kdb", $($arg)+) } }
87#[macro_export]
88macro_rules! info_kdb  { ($($arg:tt)+) => { $crate::re_exports::log::info!( target: "kdb", $($arg)+) } }
89#[macro_export]
90macro_rules! warn_kdb  { ($($arg:tt)+) => { $crate::re_exports::log::warn!( target: "kdb", $($arg)+) } }
91#[macro_export]
92macro_rules! error_kdb { ($($arg:tt)+) => { $crate::re_exports::log::error!(target: "kdb", $($arg)+) } }