From 74ef83bb3f3181acd1c64c39b9884305408e9234 Mon Sep 17 00:00:00 2001 From: TimonPost Date: Sat, 11 Aug 2018 18:08:26 +0200 Subject: [PATCH] Quick fix logging example --- examples/program_examples/logging.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/program_examples/logging.rs b/examples/program_examples/logging.rs index ac92ecc..9d728a0 100644 --- a/examples/program_examples/logging.rs +++ b/examples/program_examples/logging.rs @@ -109,10 +109,12 @@ fn handle_incoming_logs(more_jobs_rx: SyncFlagRx, queue: WorkQueue) while more_jobs_rx.get().unwrap() { // If work is available, do that work. if let Some(work) = queue.get_work() { + let mut log = work; + log.push('\n'); // write the log - write!(screen, "{}\n", work); - screen.flush(); + screen.stdout.write_string(log); + screen.stdout.flush(); } std::thread::yield_now(); } @@ -134,7 +136,7 @@ fn log_with_different_threads(more_jobs_tx: SyncFlagTx, queue: WorkQueue let thread = thread::spawn(move || { // log 400 messages - for log_entry_count in 1..400 + for log_entry_count in 1..10000 { thread_queue.add_work(format!("Log {} from thread {} ",log_entry_count, thread_num)); more_jobs.set(true);