add format util to log suite
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
877c04de52
commit
1bb4021b90
2 changed files with 19 additions and 0 deletions
18
src/core/log/fmt.rs
Normal file
18
src/core/log/fmt.rs
Normal 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(())
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod color;
|
pub mod color;
|
||||||
|
pub mod fmt;
|
||||||
mod reload;
|
mod reload;
|
||||||
|
|
||||||
pub use reload::ReloadHandle;
|
pub use reload::ReloadHandle;
|
||||||
|
|
Loading…
Add table
Reference in a new issue