in resctl-demo/src/journal.rs [43:89]
fn format_journal_msg(msg: &JournalMsg, buf: &mut StyledString, long_fmt: bool) {
const WARNS: &[&str] = &["WARN", "ERROR", "OVERLOAD", "Failed", "exception"];
const ALERTS: &[&str] = &["Starting", "Stopped"];
let unit = msg.unit.trim_end_matches(".service");
let mut style: Style = (*COLOR_DFL).into();
if msg.priority < 6 {
style = style.combine(Effect::Bold);
}
if msg.priority < 5 {
style = style.combine(*COLOR_ALERT);
}
// systemd generates a lot of the following messages for transient units.
// It distracts without adding any value. Ignore.
if msg.msg.contains(".service: Failed to open ")
&& msg.msg.contains(".service: No such file or directory")
{
return;
}
for w in WARNS.iter() {
if msg.msg.contains(w) {
style = style.combine(*COLOR_ALERT);
break;
}
}
for a in ALERTS.iter() {
if msg.msg.contains(a) {
style = style.combine(Effect::Bold);
break;
}
}
let at = DateTime::<Local>::from(msg.at);
if long_fmt {
buf.append_styled(
format!("[{} {}] ", at.format("%b %d %T"), unit),
*COLOR_INACTIVE,
);
} else {
buf.append_styled(format!("[{} {}] ", at.format("%T"), unit), *COLOR_INACTIVE);
}
buf.append_styled(&msg.msg, style);
buf.append_plain("\n");
}