Skip to main content

amareleo_chain_tracing/
lib.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at:
4
5// http://www.apache.org/licenses/LICENSE-2.0
6
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12
13#![forbid(unsafe_code)]
14#![recursion_limit = "256"]
15
16mod trace_layers;
17pub use trace_layers::*;
18
19mod logger;
20pub use logger::*;
21
22/// macro to setup info tracing subscribers for structs implementing TracingHandlerGuard
23#[macro_export]
24macro_rules! guard_info {
25    ($guard_expr:expr, $($args:tt)*) => {
26        {
27            let _guard = (&$guard_expr).get_tracing_guard();
28            info!($($args)*);
29        }
30    };
31}
32
33/// macro to setup warn tracing subscribers for structs implementing TracingHandlerGuard
34#[macro_export]
35macro_rules! guard_warn {
36    ($guard_expr:expr, $($args:tt)*) => {
37        {
38            let _guard = (&$guard_expr).get_tracing_guard();
39            warn!($($args)*);
40        }
41    };
42}
43
44/// macro to setup error tracing subscribers for structs implementing TracingHandlerGuard
45#[macro_export]
46macro_rules! guard_error {
47    ($guard_expr:expr, $($args:tt)*) => {
48        {
49            let _guard = (&$guard_expr).get_tracing_guard();
50            error!($($args)*);
51        }
52    };
53}
54
55/// macro to setup debug tracing subscribers for structs implementing TracingHandlerGuard
56#[macro_export]
57macro_rules! guard_debug {
58    ($guard_expr:expr, $($args:tt)*) => {
59        {
60            let _guard = (&$guard_expr).get_tracing_guard();
61            debug!($($args)*);
62        }
63    };
64}
65
66/// macro to setup trace tracing subscribers for structs implementing TracingHandlerGuard
67#[macro_export]
68macro_rules! guard_trace {
69    ($guard_expr:expr, $($args:tt)*) => {
70        {
71            let _guard = (&$guard_expr).get_tracing_guard();
72            trace!($($args)*);
73        }
74    };
75}