2024-06-11 00:15:29 +00:00
|
|
|
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,
|
2024-06-11 01:26:31 +00:00
|
|
|
"<font data-mx-color=\"{color}\"><code>{level:>5}</code></font> <code>{span:^12}</code> <code>{msg}</code><br>"
|
2024-06-11 00:15:29 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
2024-06-12 18:52:24 +00:00
|
|
|
|
|
|
|
|
pub fn markdown<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result<()>
|
|
|
|
|
where
|
|
|
|
|
S: Write,
|
|
|
|
|
{
|
|
|
|
|
let level = level.as_str().to_uppercase();
|
|
|
|
|
writeln!(out, "`{level:>5}` `{span:^12}` `{msg}`")?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn markdown_table<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result<()>
|
|
|
|
|
where
|
|
|
|
|
S: Write,
|
|
|
|
|
{
|
|
|
|
|
let level = level.as_str().to_uppercase();
|
2024-08-02 22:18:16 +00:00
|
|
|
writeln!(out, "| {level:>5} | {span:^12} | {msg} |")?;
|
2024-06-12 18:52:24 +00:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn markdown_table_head<S>(out: &mut S) -> Result<()>
|
|
|
|
|
where
|
|
|
|
|
S: Write,
|
|
|
|
|
{
|
2024-08-02 22:18:16 +00:00
|
|
|
write!(out, "| level | span | message |\n| ------: | :-----: | :------- |\n")?;
|
2024-06-12 18:52:24 +00:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|