| 1 | use simple_logger::SimpleLogger; |
| 2 | |
| 3 | fn main() { |
| 4 | SimpleLogger::new().with_threads(true).init().unwrap(); |
| 5 | |
| 6 | log::info!("Main thread logs here."); |
| 7 | |
| 8 | // If the "nightly" feature is enabled, the output will include thread ids. |
| 9 | for _ in 1..=5 { |
| 10 | std::thread::spawn(|| { |
| 11 | log::info!("Unnamed thread logs here."); |
| 12 | }) |
| 13 | .join() |
| 14 | .unwrap(); |
| 15 | } |
| 16 | |
| 17 | std::thread::Builder::new() |
| 18 | .name("named_thread".to_string()) |
| 19 | .spawn(|| { |
| 20 | log::info!("Named thread logs here."); |
| 21 | }) |
| 22 | .unwrap() |
| 23 | .join() |
| 24 | .unwrap(); |
| 25 | } |