Rust · 465 bytes Raw Blame History
1 use std::time::{SystemTime, UNIX_EPOCH};
2
3 pub fn info(message: &str) {
4 emit("info", message);
5 }
6
7 pub fn warn(message: &str) {
8 emit("warn", message);
9 }
10
11 pub fn error(message: &str) {
12 emit("error", message);
13 }
14
15 fn emit(level: &str, message: &str) {
16 let timestamp = SystemTime::now()
17 .duration_since(UNIX_EPOCH)
18 .map_or(0, |duration| duration.as_secs());
19 eprintln!("ts={timestamp} level={level} component=garwarp msg={message}");
20 }
21