mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 23:40:05 +08:00
add MessageType#print
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user