[dev] save time format string in constant

This commit is contained in:
Paul Schulze 2022-08-12 17:33:06 +02:00 committed by ddidderr
parent 6acd42ecc2
commit 218f470041
Signed by: ddidderr
GPG Key ID: 3841F1C27E6F0E14

View File

@ -13,6 +13,8 @@ use std::{
},
};
const TIME_FORMAT: &str = "%H:%M:%S%.6f";
type LogtimesResult = Result<(), IoError>;
#[inline(always)]
@ -20,14 +22,14 @@ fn print_time<T>(output: &mut T) -> LogtimesResult
where
T: Write,
{
let date_now = Local::now().format("%H:%M:%S%.6f");
let date_now = Local::now().format(TIME_FORMAT);
write!(output, "[{}] ", &date_now)
}
#[inline(always)]
fn print_time_color(output: &mut StdoutLock) -> Result<(), std::io::Error> {
let date_now = Local::now().format("%H:%M:%S%.6f");
let date_now = Local::now().format(TIME_FORMAT);
let color_green = "\x1b\x5b\x30\x3b\x33\x32\x6d";
let color_off = "\x1b\x5b\x30\x6d";