1use log::{info, warn};
2use std::{thread, time::Duration};
3use tree_logger::{TreeLogger, profile};
4
5fn main() {
6 TreeLogger::new()
7 .with_colors(true)
8 .with_threads(true)
9 .init()
10 .unwrap();
11
12 warn!("Basic warning, not nested, shows up immediately");
13 let result = profile!("First span", || {
14 info!("Info inside a span. Doesn't print until the whole span is done");
15
16 thread::sleep(Duration::from_secs(2));
17
18 profile!("Child span #1", || {
19 info!("Info inside a child span #1");
20 thread::sleep(Duration::from_secs(1));
21 });
22
23 profile!("Child span #2", || {
24 info!("Info inside a child span #2");
25 thread::sleep(Duration::from_secs(1));
26 });
27
28 42 });
30
31 info!("Profile returns a value: {result}");
32}