add format util to log suite

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-11 00:15:29 +00:00
parent 877c04de52
commit 1bb4021b90
2 changed files with 19 additions and 0 deletions

18
src/core/log/fmt.rs Normal file
View file

@ -0,0 +1,18 @@
use std::fmt::Write;
use super::{color, Level};
use crate::Result;
pub fn html<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result<()>
where
S: Write,
{
let color = color::code_tag(level);
let level = level.as_str().to_uppercase();
write!(
out,
"<font data-mx-color=\"{color}\"><code>{level:>5}</code></font> <code>{span:<12}</code> <code>{msg}</code><br>"
)?;
Ok(())
}

View file

@ -1,4 +1,5 @@
pub mod color;
pub mod fmt;
mod reload;
pub use reload::ReloadHandle;