Closed hansjorg closed 6 years ago
When logging from two different threads, statements written to stdout and stderr might become interleaved.
Example:
#[macro_use] extern crate log; extern crate simplelog; use simplelog::{LevelFilter, SimpleLogger}; use std::{thread, time}; fn main() { let _ = SimpleLogger::init(LevelFilter::Debug, simplelog::Config::default()); thread::spawn(move || { loop { info!("from thread 1"); } }); thread::spawn(move || { loop { error!("from thread 2"); } }); info!("starting"); thread::sleep(time::Duration::from_millis(1000)); }
Example output:
19:51:07 [INFO] starting 19:51:07 [INFO] from thread 1 19:51:07 [INFO] from thread 1 19:51:07 [INFO] from thread 1 19:51:019:51:07 [INFO] from thread 1 7 [ERROR] from thread 2 19:51:07 [INFO] from thread 1 19:51:07 19:51:07 [INFO] from thread 1 [ERROR] from thread 2 1919:51:07 [INFO] from thread 1 :51:07 [19:51:07 [INFO] from thread 1 ERROR] from thread 2 1919:51:07 [INFO] from thread 1
When logging from two different threads, statements written to stdout and stderr might become interleaved.
Example:
Example output: