std_out_separate_thread_thread_names/
thread-names.rs

1use std::thread;
2
3use rslogger::Logger;
4use log::{info, warn, error};
5
6fn main() {
7    Logger::new()
8        .with_level(log::LevelFilter::Trace)
9        .with_local_timestamps()
10        .with_thread()
11        .add_writer_stdout(false, None)
12        .init().unwrap();
13
14    let handler1 = thread::Builder::new().name("Thread 1".to_string()).spawn(move | | {
15        for i in 0..10 {
16            info!("This is a info, i: {i}");
17        }
18    }).unwrap();
19
20    let handler2 = thread::Builder::new().name("Thread 2".to_string()).spawn(move | | {
21        for i in 0..10 {
22            info!("This is a info, i: {i}");
23        }
24    }).unwrap();
25    
26    warn!("Warning on main!");
27
28    handler1.join().unwrap();
29    handler2.join().unwrap();
30
31    log::logger().flush();
32}