1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 07:30:05 +08:00

add MessageType#print

This commit is contained in:
2020-05-02 18:53:48 +08:00
parent d7ffd4ca6c
commit 7bfffc7bb6

View File

@@ -8,6 +8,7 @@ lazy_static! {
static ref PRINT_MESSAGE_LOCK: Arc<Mutex<()>> = 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();
}