tree_decorator/macros/
log.rs

1/// Tree item call with a [`log::debug!`].
2///
3/// It don't do anything extra, just calls [`tree_item!`] and
4/// gives the returned value to a [`log::debug!`].
5///
6/// Works the same as:
7///
8/// ```
9/// use tree_decorator::tree_item;
10///
11/// log::debug!("{}", tree_item!(dashed, "My tree item"));
12/// ```
13///
14/// But looks more concise and simple:
15///
16/// ```
17/// use tree_decorator::tree_item_debug;
18///
19/// tree_item_debug!(dashed, "My tree item");
20/// ```
21#[macro_export]
22macro_rules! tree_item_debug {
23    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )* , $str:literal $($arg:tt)*) => {
24        log::debug!(
25            "{}", 
26            $crate::tree_item!($first_style_name $( : $ first_style_value )? $( ; $other_style_name $( : $other_style_value )? )* , $str $( $arg )*)
27        );
28    };
29
30    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )*) => {
31        log::debug!(
32            "{}", 
33            $crate::tree_item!($first_style_name $( : $first_style_value )? $( ; $other_style_name $( : $other_style_value )? )*)
34        );
35    };
36
37    ($str:literal $($arg:tt)*) => {
38        log::debug!(
39            "{}", 
40            $crate::tree_item!($str $( $arg )*)
41        );
42    };
43
44    () => {
45        log::debug!(
46            "{}", 
47            $crate::tree_item!()
48        );
49    };
50}
51
52/// Tree item call with a [`log::error!`].
53///
54/// It don't do anything extra, just calls [`tree_item!`] and
55/// gives the returned value to a [`log::error!`].
56///
57/// Works the same as:
58///
59/// ```
60/// use tree_decorator::tree_item;
61///
62/// log::error!("{}", tree_item!(dashed, "My tree item"));
63/// ```
64///
65/// But looks more concise and simple:
66///
67/// ```
68/// use tree_decorator::tree_item_error;
69///
70/// tree_item_error!(dashed, "My tree item");
71/// ```
72#[macro_export]
73macro_rules! tree_item_error {
74    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )* , $str:literal $($arg:tt)*) => {
75        log::error!(
76            "{}", 
77            $crate::tree_item!($first_style_name $( : $ first_style_value )? $( ; $other_style_name $( : $other_style_value )? )* , $str $( $arg )*)
78        );
79    };
80
81    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )*) => {
82        log::error!(
83            "{}", 
84            $crate::tree_item!($first_style_name $( : $first_style_value )? $( ; $other_style_name $( : $other_style_value )? )*)
85        );
86    };
87
88    ($str:literal $($arg:tt)*) => {
89        log::error!(
90            "{}", 
91            $crate::tree_item!($str $( $arg )*)
92        );
93    };
94
95    () => {
96        log::error!(
97            "{}", 
98            $crate::tree_item!()
99        );
100    };
101}
102
103/// Tree item call with a [`log::info!`].
104///
105/// It don't do anything extra, just calls [`tree_item!`] and
106/// gives the returned value to a [`log::info!`].
107///
108/// Works the same as:
109///
110/// ```
111/// use tree_decorator::tree_item;
112///
113/// log::info!("{}", tree_item!(dashed, "My tree item"));
114/// ```
115///
116/// But looks more concise and simple:
117///
118/// ```
119/// use tree_decorator::tree_item_info;
120///
121/// tree_item_info!(dashed, "My tree item");
122/// ```
123#[macro_export]
124macro_rules! tree_item_info {
125    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )* , $str:literal $($arg:tt)*) => {
126        log::info!(
127            "{}", 
128            $crate::tree_item!($first_style_name $( : $ first_style_value )? $( ; $other_style_name $( : $other_style_value )? )* , $str $( $arg )*)
129        );
130    };
131
132    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )*) => {
133        log::info!(
134            "{}", 
135            $crate::tree_item!($first_style_name $( : $first_style_value )? $( ; $other_style_name $( : $other_style_value )? )*)
136        );
137    };
138
139    ($str:literal $($arg:tt)*) => {
140        log::info!(
141            "{}", 
142            $crate::tree_item!($str $( $arg )*)
143        );
144    };
145
146    () => {
147        log::info!(
148            "{}", 
149            $crate::tree_item!()
150        );
151    };
152}
153
154/// Tree item call with a [`log::trace!`].
155///
156/// It don't do anything extra, just calls [`tree_item!`] and
157/// gives the returned value to a [`log::trace!`].
158///
159/// Works the same as:
160///
161/// ```
162/// use tree_decorator::tree_item;
163///
164/// log::trace!("{}", tree_item!(dashed, "My tree item"));
165/// ```
166///
167/// But looks more concise and simple:
168///
169/// ```
170/// use tree_decorator::tree_item_trace;
171///
172/// tree_item_trace!(dashed, "My tree item");
173/// ```
174#[macro_export]
175macro_rules! tree_item_trace {
176    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )* , $str:literal $($arg:tt)*) => {
177        log::trace!(
178            "{}", 
179            $crate::tree_item!($first_style_name $( : $ first_style_value )? $( ; $other_style_name $( : $other_style_value )? )* , $str $( $arg )*)
180        );
181    };
182
183    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )*) => {
184        log::trace!(
185            "{}", 
186            $crate::tree_item!($first_style_name $( : $first_style_value )? $( ; $other_style_name $( : $other_style_value )? )*)
187        );
188    };
189
190    ($str:literal $($arg:tt)*) => {
191        log::trace!(
192            "{}", 
193            $crate::tree_item!($str $( $arg )*)
194        );
195    };
196
197    () => {
198        log::info!(
199            "{}", 
200            $crate::tree_item!()
201        );
202    };
203}
204
205
206/// Tree item call with a [`log::warn!`].
207///
208/// It don't do anything extra, just calls [`tree_item!`] and
209/// gives the returned value to a [`log::warn!`].
210///
211/// Works the same as:
212///
213/// ```
214/// use tree_decorator::tree_item;
215///
216/// log::warn!("{}", tree_item!(dashed, "My tree item"));
217/// ```
218///
219/// But looks more concise and simple:
220///
221/// ```
222/// use tree_decorator::tree_item_warn;
223///
224/// tree_item_warn!(dashed, "My tree item");
225/// ```
226#[macro_export]
227macro_rules! tree_item_warn {
228    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )* , $str:literal $($arg:tt)*) => {
229        log::warn!(
230            "{}", 
231            $crate::tree_item!($first_style_name $( : $ first_style_value )? $( ; $other_style_name $( : $other_style_value )? )* , $str $( $arg )*)
232        );
233    };
234
235    ($first_style_name:ident $( : $first_style_value:expr )? $( ; $other_style_name:ident $( : $other_style_value:expr )? )*) => {
236        log::warn!(
237            "{}", 
238            $crate::tree_item!($first_style_name $( : $first_style_value )? $( ; $other_style_name $( : $other_style_value )? )*)
239        );
240    };
241
242    ($str:literal $($arg:tt)*) => {
243        log::warn!(
244            "{}", 
245            $crate::tree_item!($str $( $arg )*)
246        );
247    };
248
249    () => {
250        log::warn!(
251            "{}", 
252            $crate::tree_item!()
253        );
254    };
255}