From 3e890eb30768d0ca25ce29681364af47d38759ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos=20P=2E=20Bezerra?= Date: Mon, 18 Nov 2024 00:27:22 -0300 Subject: [PATCH] chore: rename functions and fix wrong logs --- src/utils/logger.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utils/logger.rs b/src/utils/logger.rs index ceaee325..5156308e 100644 --- a/src/utils/logger.rs +++ b/src/utils/logger.rs @@ -14,7 +14,7 @@ pub fn shutdown_logger_and_wait() { /// Asks logger to flush all messages, useful before starting STDIN interaction. #[track_caller] pub fn flush_messages() { - logger_thread::send_flush_message_and_wait(); + logger_thread::send_flush_command_and_wait(); } /// An `[INFO]` log to be displayed if we're not running accessibility mode. @@ -42,7 +42,7 @@ pub fn info_accessible(contents: String) { #[track_caller] fn info_with_accessibility(contents: String, accessible: bool) { - logger_thread::send_log_message(PrintMessage { + logger_thread::send_print_command(PrintMessage { contents, accessible, level: MessageLevel::Info, @@ -51,7 +51,7 @@ fn info_with_accessibility(contents: String, accessible: bool) { #[track_caller] pub fn warning(contents: String) { - logger_thread::send_log_message(PrintMessage { + logger_thread::send_print_command(PrintMessage { contents, // Warnings are important and unlikely to flood, so they should be displayed accessible: true, @@ -76,7 +76,7 @@ struct PrintMessage { } impl PrintMessage { - fn to_processed_message(&self) -> Option { + fn to_formatted_message(&self) -> Option { match self.level { MessageLevel::Info => { if self.accessible { @@ -134,21 +134,21 @@ mod logger_thread { } #[track_caller] - pub(super) fn send_log_message(msg: PrintMessage) { + pub(super) fn send_print_command(msg: PrintMessage) { get_sender() .send(LoggerCommand::Print(msg)) - .expect("Failed to send print message"); + .expect("Failed to send print command"); } #[track_caller] - pub(super) fn send_flush_message_and_wait() { + pub(super) fn send_flush_command_and_wait() { let barrier = Arc::new(Barrier::new(2)); get_sender() .send(LoggerCommand::Flush { finished_barrier: barrier.clone(), }) - .expect("Failed to send shutdown message"); + .expect("Failed to send flush command"); barrier.wait(); } @@ -161,7 +161,7 @@ mod logger_thread { .send(LoggerCommand::FlushAndShutdown { finished_barrier: barrier.clone(), }) - .expect("Failed to send shutdown message"); + .expect("Failed to send shutdown command"); barrier.wait(); } @@ -189,7 +189,7 @@ mod logger_thread { match msg { LoggerCommand::Print(msg) => { // Append message to buffer - if let Some(msg) = msg.to_processed_message() { + if let Some(msg) = msg.to_formatted_message() { buffer.push(msg); }