use std::sync::Arc; use super::{ super::{Level, fmt}, Closure, Data, }; use crate::{Result, SyncMutex}; pub fn fmt_html(out: Arc>) -> Box where S: std::fmt::Write + Send + 'static, { fmt(fmt::html, out) } pub fn fmt_markdown(out: Arc>) -> Box where S: std::fmt::Write + Send + 'static, { fmt(fmt::markdown, out) } pub fn fmt(fun: F, out: Arc>) -> Box where F: Fn(&mut S, &Level, &str, &str) -> Result<()> + Send + Sync + Copy + 'static, S: std::fmt::Write + Send + 'static, { Box::new(move |data| call(fun, &mut *out.lock(), &data)) } fn call(fun: F, out: &mut S, data: &Data<'_>) where F: Fn(&mut S, &Level, &str, &str) -> Result<()>, S: std::fmt::Write, { fun(out, &data.level(), data.span_name(), data.message()).expect("log line appended"); }