From 7bfffc7bb6aed89e4c91c5fbbc66e13c1d460c0b Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 2 May 2020 18:53:48 +0800 Subject: [PATCH] add MessageType#print --- src/util_msg.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util_msg.rs b/src/util_msg.rs index c11d1ec..7b0e3fe 100644 --- a/src/util_msg.rs +++ b/src/util_msg.rs @@ -8,6 +8,7 @@ lazy_static! { static ref PRINT_MESSAGE_LOCK: Arc> = Arc::new(Mutex::new(())); } +#[derive(Clone, Copy)] pub enum MessageType { INFO, OK, WARN, ERROR, DEBUG, } pub fn is_atty() -> bool { @@ -59,6 +60,12 @@ pub fn print_message(mt: MessageType, message: &str) { } } +impl MessageType { + pub fn print(&self, message: &str) { + print_message(*self, message); + } +} + pub fn flush_stdout() { io::stdout().flush().ok(); }