pub use custom::CustomLayout;
pub use identical::IdenticalLayout;
#[cfg(feature = "json")]
pub use json::JsonLayout;
pub use kv::KvDisplay;
pub use text::LevelColor;
pub use text::TextLayout;
mod custom;
mod identical;
#[cfg(feature = "json")]
mod json;
mod kv;
mod text;
#[derive(Debug)]
pub enum Layout {
Identical(IdenticalLayout),
Text(TextLayout),
#[cfg(feature = "json")]
Json(JsonLayout),
Custom(CustomLayout),
}
impl Layout {
pub(crate) fn format<F>(&self, record: &log::Record, f: &F) -> anyhow::Result<()>
where
F: Fn(&log::Record) -> anyhow::Result<()>,
{
match self {
Layout::Identical(layout) => {
layout.format(record, &|args| f(&record.to_builder().args(args).build()))
}
Layout::Text(layout) => {
layout.format(record, &|args| f(&record.to_builder().args(args).build()))
}
#[cfg(feature = "json")]
Layout::Json(layout) => {
layout.format(record, &|args| f(&record.to_builder().args(args).build()))
}
Layout::Custom(layout) => {
layout.format(record, &|args| f(&record.to_builder().args(args).build()))
}
}
}
}