fluxion_exec/
logging.rs

1// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
2// Licensed under the Apache License, Version 2.0
3// http://www.apache.org/licenses/LICENSE-2.0
4
5#[cfg(feature = "tracing")]
6#[macro_export]
7macro_rules! error {
8    ($($arg:tt)*) => {{
9        tracing::error!($($arg)*);
10    }};
11}
12
13#[cfg(feature = "tracing")]
14#[macro_export]
15macro_rules! warn {
16    ($($arg:tt)*) => {{
17        tracing::warn!($($arg)*);
18    }};
19}
20
21#[cfg(feature = "tracing")]
22#[macro_export]
23macro_rules! info {
24    ($($arg:tt)*) => {{
25        tracing::info!($($arg)*);
26    }};
27}
28
29// With std available (runtime features enabled)
30#[cfg(all(
31    not(feature = "tracing"),
32    any(
33        feature = "runtime-tokio",
34        feature = "runtime-smol",
35        feature = "runtime-async-std",
36        target_arch = "wasm32"
37    )
38))]
39#[macro_export]
40macro_rules! error {
41    ($($arg:tt)*) => {{
42        eprintln!($($arg)*);
43    }};
44}
45
46#[cfg(all(
47    not(feature = "tracing"),
48    any(
49        feature = "runtime-tokio",
50        feature = "runtime-smol",
51        feature = "runtime-async-std",
52        target_arch = "wasm32"
53    )
54))]
55#[macro_export]
56macro_rules! warn {
57    ($($arg:tt)*) => {{
58        eprintln!($($arg)*);
59    }};
60}
61
62#[cfg(all(
63    not(feature = "tracing"),
64    any(
65        feature = "runtime-tokio",
66        feature = "runtime-smol",
67        feature = "runtime-async-std",
68        target_arch = "wasm32"
69    )
70))]
71#[macro_export]
72macro_rules! info {
73    ($($arg:tt)*) => {{
74        println!($($arg)*);
75    }};
76}
77
78// In no_std mode (no runtime features), logging is a no-op
79#[cfg(all(
80    not(feature = "tracing"),
81    not(any(
82        feature = "runtime-tokio",
83        feature = "runtime-smol",
84        feature = "runtime-async-std",
85        target_arch = "wasm32"
86    ))
87))]
88#[macro_export]
89macro_rules! error {
90    ($($arg:tt)*) => {{}};
91}
92
93#[cfg(all(
94    not(feature = "tracing"),
95    not(any(
96        feature = "runtime-tokio",
97        feature = "runtime-smol",
98        feature = "runtime-async-std",
99        target_arch = "wasm32"
100    ))
101))]
102#[macro_export]
103macro_rules! warn {
104    ($($arg:tt)*) => {{}};
105}
106
107#[cfg(all(
108    not(feature = "tracing"),
109    not(any(
110        feature = "runtime-tokio",
111        feature = "runtime-smol",
112        feature = "runtime-async-std",
113        target_arch = "wasm32"
114    ))
115))]
116#[macro_export]
117macro_rules! info {
118    ($($arg:tt)*) => {{}};
119}