1pub mod config;
7pub mod console;
8pub mod init;
9pub mod kv_layer;
10pub mod otel_fmt;
11
12pub use config::{LogLevel, XLOG_CONFIG_KEY, XLogConfig};
13pub use kv_layer::SpanKvFields;
14
15use std::sync::atomic::{AtomicBool, Ordering};
16
17static REGISTERED: AtomicBool = AtomicBool::new(false);
19
20pub fn register_hook() {
22 if REGISTERED
23 .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
24 .is_err()
25 {
26 return;
27 }
28
29 crate::before_start!(init::init_xlog, crate::xhook::HookOptions::new().order(30));
30 crate::before_stop!(
31 init::shutdown_xlog,
32 crate::xhook::HookOptions::new().order(i32::MAX - 30)
33 );
34}
35
36#[macro_export]
51macro_rules! xlog_kv {
52 ($($arg:tt)*) => {
53 tracing::info_span!("", $($arg)*).entered()
54 };
55}
56
57#[macro_export]
61macro_rules! xlog_info {
62 ($($arg:tt)*) => {
63 tracing::info!($($arg)*)
64 };
65}
66
67#[macro_export]
69macro_rules! xlog_error {
70 ($($arg:tt)*) => {
71 tracing::error!($($arg)*)
72 };
73}
74
75#[macro_export]
77macro_rules! xlog_warn {
78 ($($arg:tt)*) => {
79 tracing::warn!($($arg)*)
80 };
81}
82
83#[macro_export]
85macro_rules! xlog_debug {
86 ($($arg:tt)*) => {
87 tracing::debug!($($arg)*)
88 };
89}