1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use time::OffsetDateTime;
use time::macros::format_description;
const DATE_FORMAT_STR: &[time::format_description::FormatItem<'static>] = format_description!(version = 2, "[month]/[day]/[year] [hour repr:12]:[minute]:[second] [period]");
fn _gettimestamp() -> String {
let local_time = OffsetDateTime::now_local().unwrap();
local_time.format(&DATE_FORMAT_STR).unwrap()
}
pub fn loghelper_formatlogline(loglevel: &str, message: &str) -> String {
let timestamp = _gettimestamp();
format!("{timestamp} [{loglevel:<5}] {message}\n")
}