-
Notifications
You must be signed in to change notification settings - Fork 5
/
style.rs
33 lines (31 loc) · 939 Bytes
/
style.rs
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
32
33
/// Log message styling.
///
/// Adapted from <https://gitlab.com/limira-rs/wasm-logger/-/blob/0c16227/src/lib.rs#L72-85>
pub(crate) struct Style<'s> {
pub trace: &'s str,
pub debug: &'s str,
pub info: &'s str,
pub warn: &'s str,
pub error: &'s str,
pub file_line: &'s str,
pub text: &'s str,
}
impl Style<'static> {
/// Returns default style values.
pub const fn default() -> Self {
macro_rules! bg_color {
($color:expr) => {
concat!("color: white; padding: 0 3px; background: ", $color, ";")
};
};
Style {
trace: bg_color!("gray"),
debug: bg_color!("blue"),
info: bg_color!("green"),
warn: bg_color!("orange"),
error: bg_color!("darkred"),
file_line: "font-weight: bold; color: inherit",
text: "background: inherit; color: inherit",
}
}
}