lib.rs

 1pub use tracing::{Level, field};
 2
 3#[cfg(ztracing)]
 4pub use tracing::{
 5    Span, debug_span, error_span, event, info_span, instrument, span, trace_span, warn_span,
 6};
 7#[cfg(not(ztracing))]
 8pub use ztracing_macro::instrument;
 9
10#[cfg(not(ztracing))]
11pub use __consume_all_tokens as trace_span;
12#[cfg(not(ztracing))]
13pub use __consume_all_tokens as info_span;
14#[cfg(not(ztracing))]
15pub use __consume_all_tokens as debug_span;
16#[cfg(not(ztracing))]
17pub use __consume_all_tokens as warn_span;
18#[cfg(not(ztracing))]
19pub use __consume_all_tokens as error_span;
20#[cfg(not(ztracing))]
21pub use __consume_all_tokens as event;
22#[cfg(not(ztracing))]
23pub use __consume_all_tokens as span;
24
25#[cfg(not(ztracing))]
26#[macro_export]
27macro_rules! __consume_all_tokens {
28    ($($t:tt)*) => {
29        $crate::Span
30    };
31}
32
33#[cfg(not(ztracing))]
34pub struct Span;
35
36#[cfg(not(ztracing))]
37impl Span {
38    pub fn current() -> Self {
39        Self
40    }
41
42    pub fn enter(&self) {}
43
44    pub fn record<T, S>(&self, _t: T, _s: S) {}
45}
46
47#[cfg(ztracing)]
48pub fn init() {
49    zlog::info!("Starting tracy subscriber, you can now connect the profiler");
50    use tracing_subscriber::prelude::*;
51    tracing::subscriber::set_global_default(
52        tracing_subscriber::registry().with(tracing_tracy::TracyLayer::default()),
53    )
54    .expect("setup tracy layer");
55}
56
57#[cfg(not(ztracing))]
58pub fn init() {}