1pub use tracing::{Level, field};
2
3#[cfg(feature = "tracy")]
4pub use tracing::{
5 Span, debug_span, error_span, event, info_span, instrument, span, trace_span, warn_span,
6};
7#[cfg(not(feature = "tracy"))]
8pub use ztracing_macro::instrument;
9
10#[cfg(not(feature = "tracy"))]
11pub use __consume_all_tokens as trace_span;
12#[cfg(not(feature = "tracy"))]
13pub use __consume_all_tokens as info_span;
14#[cfg(not(feature = "tracy"))]
15pub use __consume_all_tokens as debug_span;
16#[cfg(not(feature = "tracy"))]
17pub use __consume_all_tokens as warn_span;
18#[cfg(not(feature = "tracy"))]
19pub use __consume_all_tokens as error_span;
20#[cfg(not(feature = "tracy"))]
21pub use __consume_all_tokens as event;
22#[cfg(not(feature = "tracy"))]
23pub use __consume_all_tokens as span;
24
25#[cfg(not(feature = "tracy"))]
26#[macro_export]
27macro_rules! __consume_all_tokens {
28 ($($t:tt)*) => {
29 $crate::Span
30 };
31}
32
33#[cfg(not(feature = "tracy"))]
34pub struct Span;
35
36#[cfg(not(feature = "tracy"))]
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(feature = "tracy")]
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(feature = "tracy"))]
58pub fn init() {}
59
60/// Returns true if this build was compiled with Tracy profiling support.
61///
62/// When true, `init()` will set up the Tracy subscriber and the application
63/// can be profiled by connecting Tracy profiler to it.
64#[cfg(feature = "tracy")]
65pub const fn is_enabled() -> bool {
66 true
67}
68
69/// Returns true if this build was compiled with Tracy profiling support.
70///
71/// When true, `init()` will set up the Tracy subscriber and the application
72/// can be profiled by connecting Tracy profiler to it.
73#[cfg(not(feature = "tracy"))]
74pub const fn is_enabled() -> bool {
75 false
76}