1pub fn _timestamp() -> String {
6 unsafe {
7 let mut t: libc::time_t = 0;
8 libc::time(&mut t);
9 let mut tm: libc::tm = std::mem::zeroed();
10 libc::localtime_r(&t, &mut tm);
11 format!("[{:02}:{:02}:{:02}]", tm.tm_hour, tm.tm_min, tm.tm_sec)
12 }
13}
14
15macro_rules! log_info {
16 ($($arg:tt)*) => {
17 println!("{} [INFO] {}", crate::log::_timestamp(), format!($($arg)*))
18 };
19}
20
21macro_rules! log_warn {
22 ($($arg:tt)*) => {
23 println!("{} [WARN] {}", crate::log::_timestamp(), format!($($arg)*))
24 };
25}
26
27macro_rules! log_error {
28 ($($arg:tt)*) => {
29 println!("{} [ERROR] {}", crate::log::_timestamp(), format!($($arg)*))
30 };
31}