mirror of
https://github.com/jht5945/rust_util.git
synced 2026-01-12 07:10:05 +08:00
Compare commits
2 Commits
7811e29921
...
d218e1edd5
| Author | SHA1 | Date | |
|---|---|---|---|
| d218e1edd5 | |||
| 854f619518 |
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rust_util"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "Hatter's Rust Util"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use std::{
|
||||
io::{self, Write},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref IS_ATTY: bool = is_atty();
|
||||
static ref PRINT_MESSAGE_LOCK: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
|
||||
}
|
||||
|
||||
pub enum MessageType { INFO, OK, WARN, ERROR, DEBUG, }
|
||||
@@ -35,8 +37,10 @@ pub fn print_color_and_flush(color: Option<term::color::Color>, is_bold: bool, m
|
||||
}
|
||||
|
||||
pub fn print_message_ex(color: Option<term::color::Color>, h: &str, message: &str) {
|
||||
let mut lock = PRINT_MESSAGE_LOCK.lock().unwrap();
|
||||
print_color(color, true, h);
|
||||
println!(" {}", message);
|
||||
*lock += 1;
|
||||
}
|
||||
|
||||
pub fn print_message(mt: MessageType, message: &str) {
|
||||
|
||||
Reference in New Issue
Block a user